加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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);
}

但我得到错误:
“呼叫者未通过该服务进行身份验证”
System.ServiceModel ….无法满足安全令牌的请求,因为身份验证失败…

我试图模仿的凭据是服务所在框的valide windows凭证.

有什么想法吗?

解决方法

为了支持您的场景,您需要了解 Protocol Transition和 Constrained Delegation的工作原理.您需要配置Active Directory和WCF服务端点以支持此功能.请注意服务主体名称(SPN)的使用.请查看以下链接,看看它们是否对您有所帮助.本文提供了一个示例,演示了完成此工作所需的完整端到端配置.

How To: Impersonate the Original Caller in WCF Calling from a Web Application

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读