c# – WCF Windows身份验证安全性错误
发布时间:2020-12-15 07:54:44 所属栏目:百科 来源:网络整理
导读:我有一些代码尝试模拟调用者的 Windows安全设置,然后连接到另一台机器上的另一个WCF服务 WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity;using (callerWindowsIdentity.Impersonate()){ NetTcpBinding binding =
我有一些代码尝试模拟调用者的
Windows安全设置,然后连接到另一台机器上的另一个WCF服务
WindowsIdentity callerWindowsIdentity = ServiceSecurityContext.Current.WindowsIdentity; using (callerWindowsIdentity.Impersonate()) { NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; EndpointAddress endpoint = new EndpointAddress(new Uri("net.tcp://serverName:9990/TestService1")); ChannelFactory<WCFTest.ConsoleHost.IService1> channel = new ChannelFactory<WCFTest.ConsoleHost.IService1>(binding,endpoint); WCFTest.ConsoleHost.IService1 service = channel.CreateChannel(); return service.PrintMessage(msg); } 但我得到错误: 我试图模仿的凭据是服务所在框的valide windows凭证. 有什么想法吗? 解决方法
为了支持您的场景,您需要了解
Protocol Transition和
Constrained Delegation的工作原理.您需要配置Active Directory和WCF服务端点以支持此功能.请注意服务主体名称(SPN)的使用.请查看以下链接,看看它们是否对您有所帮助.本文提供了一个示例,演示了完成此工作所需的完整端到端配置.
How To: Impersonate the Original Caller in WCF Calling from a Web Application (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |