调用WCF服务时,“调用者未通过服务进行身份验证”异常?

时间:2011-03-03 18:19:56

标签: wcf

我有一个调用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();

0 个答案:

没有答案