我有一个调用WCF服务的网络应用程序
问题是,对于某些用户,我得到The caller was not authenticated by the service
的例外,而对其他用户则有效。我无法弄清楚为什么会有区别。我想补充一点,我使用的是Windows身份验证。
我的代码是:
binding = new WSHttpBinding(SecurityMode.Message);
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
binding.Security.Message.NegotiateServiceCredential = true;
binding.Security.Message.EstablishSecurityContext = false;
// create the channel factory for the service proxy
factory = new ChannelFactory<IWCF>(
binding,
new EndpointAddress(
new Uri(
CriptographyService.Decrypt(
ConfigurationSettings.AppSettings["WCF"]
)
),
EndpointIdentity.CreateUpnIdentity(
CriptographyService.Decrypt(
ConfigurationSettings.AppSettings["Identity"]
)
)
)
);
factory.Credentials.Windows.AllowedImpersonationLevel =
TokenImpersonationLevel.Delegation;
// create a channel to the service
return factory.CreateChannel();