开发者

"The caller was not authenticated by the service" exception when calling WCF service?

开发者 https://www.devze.com 2023-02-14 11:53 出处:网络
I have a web app that calls a WCF service. The problem is that for some of the users I get an exception of The caller was not authenticated by the service while for others it works. I cannot figure ou

I have a web app that calls a WCF service.

The problem is that for some of the users I get an exception of The caller was not authenticated by the service while for others it works. I cannot figure out why there is a difference. I want to add that I use windows authentication.

The code I have is:

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<开发者_如何学C;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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号