Configure a WCF Service for Windows Authentication

Hi,

Sharing a simple example on how to enable Windows Authentication for a WCF Service using basicHttpBinding.

We will take an example of the OOB WCF Service that gets created when we create a new WCF Service Application.

Add the following configuration in web.config


<system.serviceModel>
<services>
<service name="WcfService2.Service1">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="myBinding" contract="WcfService2.IService1"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="myBinding" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>

&nbsp;

And enable Windows Authentication in IIS

 

Hope it helps ..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Configure a WCF Service for Windows Authentication”

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s