Shi*_*iji 2 security configuration wcf windows-authentication
我们有一个用户访问Web服务器的系统,然后Web服务器调用WCF服务.
我们希望在Web服务器上的应用程序池的Windows标识的安全上下文中调用WCF服务.
做这个的最好方式是什么?它可以完全通过web.config文件中的配置来完成.
谢谢
西拉
是的,您应该能够在配置中执行此操作:
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="WinAuth" mode="Transport">
<transport clientCredentialType="Windows" />
<bindings>
</netTcpBinding>
</bindings>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
当然,根据您的绑定,您必须在<bindings>父节点下使用不同的标记- 当然,并非所有绑定都支持所有安全模式.....
在您的端点中,使用适当的绑定,然后只引用此配置:
<endpoint name="WCFService" address="......."
binding="netTcpBinding"
bindingConfiguration="WinAuth"
contract="......" />
Run Code Online (Sandbox Code Playgroud)
应该这样做!当然,如果您需要消息安全性而不是传输安全性,那么您也可以这样做.
在您的WCF服务方法中,您可以通过检查以检查以查看是否已发送Windows凭据及其内容:
ServiceSecurityContext.Current.WindowsIdentity
Run Code Online (Sandbox Code Playgroud)
如果您没有Windows调用者,则该值为NULL,否则将显示谁呼叫您.
渣