WsHttpbinding with TransportWithMessageCredential and Windows Authentication

I have an IIS-enabled WCF service with the following binding configuration (I removed all attributes from the binding for the space) for wsHttpBinding and TransportWithMessageCredential

<wsHttpBinding> <binding name="BindingName" .../> <security mode="TransportWithMessageCredential"> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> 

with service behavior:

  <serviceBehaviors> <behavior name="ServiceBehavior"> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Windows" /> </serviceCredentials> </behavior> </serviceBehaviors> 

Anonymous authentication is disabled and Windows authentication is enabled.

On the client side, credentials are set using a valid Windows user and password, but I get the following exception on every service call:

An HTTP request is not authorized using the 'Anonymous' client authentication scheme. The authentication header received from the server was Negotiation, NTLM. ---> System.ServiceModel.Security.MessageSecurityException: The HTTP request was not authorized using the Anonymous client authentication scheme. The authentication header received from the server was Negotiation, NTLM. ---> System.Net.WebException: the remote server returned an error: (401) Unauthorized.

With its own version of the WCF service, it works fine under a valid Windows account.

Any help is appreciated.

+6
source share
1 answer

Enabling Windows authentication in IIS requires credentials to be provided at the transport level, while your configuration determines that authentication is at the message level

To resolve this issue, you must do one of the following:

1) enable anonymous access in IIS since authentication will be performed at the message level

or

2) update your security mode for transport

 <wsHttpBinding> <binding name="BindingName" .../> <security mode="Transport"> <transport clientCredentialType="Ntlm" /> </security> </binding> </wsHttpBinding> 
+2
source

Source: https://habr.com/ru/post/975057/


All Articles