title: Implement Authentication in a WCF service (non ssl)
body: <p>I have developed a .NET WCF service which uses basicHttp binding. This service is going to be hosted in IIS in an intranet and consumed by a non-Windows SAP PO client. </p>
  
  <p>This service doesn't expose any sensitive information So I do not want to invest time on signing or encrypting messages. However, I also do not want the service to be accessed by anyone who knows the URL. so some form of authentication is required. </p>
  
  <p>Can anyone please advise what would be the simplest way to authenticate my service? </p>
  
  <p><strong>UPDATE :</strong></p>
  
  <p>Thanks Keyur PATEL. I managed to host the service in IIS as per the link provided with security mode being set to "TransportCredentialOnly" </p>
  
  <p>I enabled Basic Authentication in IIS</p>
  
  <p>My windows client is able to subscribe the service however It receives below error when an operation is executed.</p>
  
  <p>"The HTTP request is unauthorized with client authentication scheme 'Basic'. The authentication header received from the server was 'Basic realm="MY SERVER NAME"'.</p>
  
  <p><strong>Server Config</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="CustomAuthentication"&gt;
            &lt;security mode="TransportCredentialOnly"&gt;
              &lt;transport clientCredentialType="Basic" proxyCredentialType="Basic"/&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="SecurityBehavior"&gt;
            &lt;serviceCredentials&gt;
              &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="SimpleService.UserNamePasswordAuthentification, App_Code/UserNameValidator"/&gt;
            &lt;/serviceCredentials&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="SecurityBehavior" name="SimpleService.SimpleService"&gt;
          &lt;endpoint address="SimpleService" binding="basicHttpBinding" bindingConfiguration="CustomAuthentication" contract="SimpleService.ISimpleService"/&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8080"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true"/&gt;
    &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p><strong>Client Config</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="BasicHttpBinding_ISimpleService"&gt;
                      &lt;security mode="TransportCredentialOnly"&gt;
                          &lt;transport clientCredentialType="Basic" /&gt;
                      &lt;/security&gt;
                  &lt;/binding&gt;
              &lt;/basicHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://MYSERVERNAME:PORT/SimpleService.svc/SimpleService"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISimpleService"
                  contract="SimpleServiceDEV.ISimpleService" name="BasicHttpBinding_ISimpleService" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>