2011年7月19日

[WCF] Enable WCF Windows Authentication

This is a very quick note on how to enable WCF windows authentication.

Well it’s simply enough but somehow I ran into some errors like [Authentication schema mismatch between server & client] or [base address prefix not match] (not really remember the actual messages, but should be close)

This article describe the steps clearly, only one thing to remember – don’t forget to enable metadata exchange endpoint, and if you did so but the error still occurs. try remove mex endpoint and enable httpGet in service behavior meta exhange section then point service behavior configuration to that section instead.

example configuration is like bellow:

   1: <system.serviceModel>



   2:     <bindings>



   3:       <basicHttpBinding>



   4:         <binding name="basicHttpBinding" allowCookies="true" bypassProxyOnLocal="true">



   5:           <security mode="TransportCredentialOnly">



   6:             <transport clientCredentialType="Windows" />



   7:           </security>



   8:         </binding>



   9:       </basicHttpBinding>



  10:       



  11:     </bindings>



  12:     



  13:     <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true">



  14:       



  15:     </serviceHostingEnvironment>



  16:     <services>



  17:       <service behaviorConfiguration="serviceDefaultBehavior" name="Services.UserProfileService">



  18:         <endpoint address="" behaviorConfiguration="basicHttp_Behavior"



  19:           binding="basicHttpBinding" bindingConfiguration="basicHttpBinding"



  20:           name="userProfileService" contract="Services.IUserProfileService">



  21:           <identity>



  22:             <dns value="localhost" />



  23:           </identity>



  24:         </endpoint>



  25:       </service>



  26:       



  27:     </services>



  28:     <behaviors>



  29:       



  30:       <serviceBehaviors>



  31:         <behavior name="serviceDefaultBehavior">



  32:           <serviceDebug includeExceptionDetailInFaults="true" />



  33:           <serviceMetadata httpGetEnabled="true" />



  34:         </behavior>



  35:       </serviceBehaviors>



  36:     </behaviors>



  37:   </system.serviceModel>


沒有留言:

Blog Archive

About Me