Search code examples
wcfwindows-authentication

Using Microsoft integrated windows authentication with WCF but without IIS


Is there a way to get the behavior of Microsoft Integrated Windows Authentication w/o having to deploy using IIS? We have our own standalone C#/WCF WebServer and we would like to add this functionality. We cannot use IIS as part of our deployment.


Solution

  • You can set the ClientCredentialType

    WebHttpBinding whb = ... ;
    whb.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
    

    and later get the WindowsIdentity with

    WindowsIdentity identity =  ServiceSecurityContext.Current.WindowsIdentity;