title: Cannot get custom authentication working in a WCF RESTful service using webHttpBinding
body: <p>I'm currently investigating WCF for implementing a RESTful service that will run through IIS.
  Currently our software offers the ability to authenticate users against a range of sources</p>
  
  <ol>
  <li><p>Our own internal user accounts stored in the database</p></li>
  <li><p>A specified windows active directory where if authentication is
      successful, a lookup is done    to find which internal account the
      winows one is linked to</p></li>
  <li>Another LDAP server e.g Novell</li>
  </ol>
  
  <p>So the way I want this to work is that a client sends an http(s) request with an
  authentication header (basic for now) over SSL, then the service will use custom 
  authentication to implement the process described above.</p>
  
  <p>For the moment I am self-hosting the service and trying to get the custom authentication 
  example working, it starts up correctly but all I get when I try to make a request from a browser 
  or a tool where i can attach an authentication header is</p>
  
  <p>"Error 101 (net::ERR_CONNECTION_RESET): The connection was reset."</p>
  
  <p>I have set a breakpoint in the custom authentication class an it is never reached, so I'm guessing its a problem with the 
  configuration.</p>
  
  <p>My app.config;</p>
  
  <pre><code>&lt;configuration&gt;
  
  ...
  
  &lt;system.serviceModel&gt;
  
      &lt;bindings&gt;
          &lt;webHttpBinding&gt;
              &lt;binding name="secure"&gt;
                  &lt;security mode="Transport"&gt;
                      &lt;transport clientCredentialType="Basic"&gt;&lt;/transport&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;
          &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
  
    &lt;services&gt;
      &lt;service name="CELCAT.RegisterMarker.RegisterMarker" behaviorConfiguration="myServiceBehavior"&gt;
        &lt;endpoint address="https://mymachine:8001/servicename" 
                  binding="webHttpBinding"
                  bindingConfiguration="secure" 
                  contract="myServiceContract" /&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="myServiceBehavior"&gt;
          &lt;serviceMetadata httpGetEnabled="True"/&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="True"/&gt;
            &lt;serviceAuthorization serviceAuthorizationManagerType="MyServiceAuthorizationManager, authenticatonassembly" /&gt;
  
            &lt;serviceCredentials&gt;
                &lt;userNameAuthentication userNamePasswordValidationMode="Custom"
                                        customUserNamePasswordValidatorType="servicenamespace, serviceassembly" /&gt;
  
                &lt;serviceCertificate findValue="certname"
                                    storeLocation="LocalMachine"
                                    storeName="My"
                                    x509FindType="FindBySubjectName" /&gt;
            &lt;/serviceCredentials&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
  
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I have read a post that said what I am trying to do is impossible out of the box with WCF
  and to achieve this I will need to write a custom module or request interceptor as describe below;</p>
  
  <p>authentication via custom module;
  <a href="http://custombasicauth.codeplex.com/" rel="nofollow">http://custombasicauth.codeplex.com/</a></p>
  
  <p>authentication via request interceptor;
  <a href="http://www.codeproject.com/KB/WCF/BasicAuthWCFRest.aspx" rel="nofollow">http://www.codeproject.com/KB/WCF/BasicAuthWCFRest.aspx</a></p>
  
  <p>This seems like it should be possible to me, so my questions are </p>
  
  <ol>
  <li>Is what i'm trying to do possible? </li>
  <li>If so what have I got wrong? or if not which work around is best?</li>
  </ol>