title: How to configure webHttpBinding using user name/password authentication
body: <p>I am working on a WCF service with webHttpBinding for json ajax calls. The service works fine until I turned on the security part. Here is my web.config. 
   
        
          
          
          
        
      
      
        
          
            
              
            
          
        
      
      
        
          
            
            
            </p>
  
  <pre><code>      &lt;serviceCredentials &gt;
          &lt;userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="UserNamePasswordValidator, WebServices" /&gt;
        &lt;/serviceCredentials&gt;
        &lt;serviceAuthorization principalPermissionMode="Custom"&gt;
          &lt;authorizationPolicies&gt;
            &lt;add policyType="AuthorizationPolicy, WebServices" /&gt;
          &lt;/authorizationPolicies&gt;
        &lt;/serviceAuthorization&gt;
        &lt;!----&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="WebHttpBehaviour"&gt;
        &lt;enableWebScript /&gt;
        &lt;webHttp automaticFormatSelectionEnabled="false" defaultBodyStyle="Wrapped" defaultOutgoingResponseFormat="Json" helpEnabled="true" /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  &lt;/behaviors&gt;
  </code></pre>
  
  <p>Here is my javascript call.
    <pre><code>$.ajax({
         headers: {
                  "Authorization": "Basic " + Base64.encode('John:Doe')
              },
              type: "POST",
              url: "https://localhost/StatusService.svc/CheckStatus",
              data: JSON.stringify({"companyName":"test"}),
              contentType: "text/json; charset=utf-8",
              dataType: "json",
              processdata: false,
              success: function (data) {
                  alert('ok!');
              },
              error: function (jqXHR, textStatus, errorThrown) {
                  alert(textStatus + ' / ' + errorThrown);
              }
          });</code></pre></p>
  
  <p>I got error message: object error when I do the ajax call. Is there anything I am doing wrong? Thanks.</p>