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>
And enable Windows Authentication in IIS
Hope it helps ..
One thought on “Configure a WCF Service for Windows Authentication”