title: WCF Service with custom username password authentication problem
body: <p>I'm trying to secure WCF service with https and username &amp; password. I'm using TransportWithMessageCredentials security mode and wsHttpBinding.
  Right now I'm having trouble with the custom UserNamePasswordValidator, when I compare hardcoded values like this </p>
  
  <pre><code>if (userName == "user" &amp;&amp; password == "pass")
      return;
  </code></pre>
  
  <p>everything works fine, but when I try to get values from database I'm getting error message</p>
  
  <blockquote>
    <p>An unsecured or incorrectly secured
    fault was received from the other
    party. See the inner FaultException
    for the fault code and detail</p>
  </blockquote>
  
  <p>Here's my web.config section</p>
  
  <pre><code>&lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="TestAuthConf" maxReceivedMessageSize="65536"&gt;
                      &lt;security mode="TransportWithMessageCredential"&gt;
                          &lt;message clientCredentialType="UserName"/&gt;
                      &lt;/security&gt;
                      &lt;readerQuotas maxArrayLength="65536" maxBytesPerRead="65536" maxStringContentLength="65536"/&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;services&gt;
              &lt;service behaviorConfiguration="TestAuthWCFService.TestAuthBehavior" name="TestAuthLibrary.App_Code.TestAuth"&gt;
                  &lt;endpoint address="" binding="wsHttpBinding" bindingConfiguration="TestAuthConf" contract="TestAuthLibrary.App_Code.ITestAuth"&gt;
                      &lt;identity&gt;
                           &lt;dns value="localhost" /&gt;
                      &lt;/identity&gt;
                  &lt;/endpoint&gt;
                  &lt;endpoint address="mex" binding="mexHttpsBinding" contract="TestAuthLibrary.App_Code.ITestAuth"/&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="TestAuthWCFService.TestAuthBehavior"&gt;
                      &lt;serviceMetadata httpsGetEnabled="true"/&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
                      &lt;serviceCredentials&gt;
                          &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="App_Code.CustomUserNameValidator, App_Code.CustomUserNameValidator"/&gt;
                      &lt;/serviceCredentials&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
  </code></pre>
  
  <p>I'm using IIS7, self-generated digital certificate, and I set up SSL to accept client certificates...</p>
  
  <p>Any help would be appriciated...</p>