【发布时间】:2009-08-13 04:58:53
【问题描述】:
我有一些代码尝试模拟调用者的 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 .... 由于身份验证失败,无法满足对安全令牌的请求...
我试图模拟的凭据是服务所在框的有效 Windows 凭据。
有什么想法吗?
【问题讨论】: