Search code examples
c#.netweb-serviceswcfwcf-security

WCF: Using Multiple Authentication Schemes on same endpoint


I have a WCF service which i host as a Windows Service. I need to support both Windows and NTLM authentication on the service endpoint.

I came across a MSDN page which explains exactly the same with .NET 4.5, here's the link:

http://msdn.microsoft.com/en-us/library/hh556235(v=vs.110).aspx

Going by this, I configured my service endpoint in code as explained in the self-hosted services section of the above link. But, when I test this doesn't work. I captured the traffic and observed that there's no HTTP 401 challenge sent by the service, instead, it directly fails with HTTP 400 Bad Request error. I believe that should have been a HTTP 401 challenge sent to client.

Did I miss anything here?


Solution

  • Well it is possible and I could make it work after 4 days of struggle, the errors HTTP Bad Request does not indicate the problem. But, As I added service metadata behavior with HttpGetEnabled it worked.

    Also, ensure if you define ServiceAuthenticationBehavior you do mark the ClientCredentialType to InheritedFromHost. This would ensure the authentication schemes as indicated by the ServiceAuthenticationBahavior are applied.

    Hope, this would save someone else's 4 days! :)