Monday, July 5, 2010

WCF Windows Authentication

When the We want to get the Windows identity inside the WCF that was hosted inside the IIS we need to do the some configuaration inside the service configuration.We will always get the Windows identiy inside the WCF service when we are working on the development server .Since the develpment server is always runs inside the integrated web server (ie inbuild webserver from VS2005).

So inorder to get the Windows identity  first and for most  we need to add the following config

   <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

This  is to enable the Compatibility then only we can acess the HTTP Context that contains the User Identity

The follwing binding which will give the Current user identity
      <binding name ="BasicHttpBindingConfig">       
        <security mode="TransportCredentialOnly">
          <transport clientCredentialType="Windows" />

we need to add this Binding inside the service where we need to access the windows identity like

<service behaviorConfiguration="SecurityConfigurationServiceBehavior" name="SecurityConfigurationService">
<endpoint address="" binding="basicHttpBinding" contract="ISecurityConfigurationService" behaviorConfiguration="SilverlightFaultBehavior"                  bindingConfiguration ="BasicHttpBindingConfig" >
            <dns value="localhost" />

After this configuration we have to ensue that no more end points are configured.

We need to enable some settings inside the IIS  to get the Windows Identity i.e  enable is Windows integrated  options


Post a Comment