title: XMLHttpRequest SOAP request with Windows Authentication
body: <p>I'm trying to make SOAP request to Microsoft server using XMLHttpRequest (firefox) with different authentication schemes allowed on the server.</p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest();
  xmlhttp.open('POST', url, true);
  xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
  xmlhttp.setRequestHeader("Connection", "keep-alive");
  
  xmlhttp.onreadystatechange = function () {
      if (xmlhttp.readyState == 4) {
          if (xmlhttp.status == 200) {
              alert(xmlhttp.responseText);
          }
      }
  }
  
  xmlhttp.send(soapRequest);
  </code></pre>
  
  <p>In this case everything works as expected. When I run this code I'll get prompted for username and password and after entering credentials I'll get response from the server. This works for Basic, Digest and Windows authentication.</p>
  
  <p>But I don't want to get prompted for credetntials so I altered the second line to</p>
  
  <pre><code>xmlhttp.open('POST', url, true, username, password);
  </code></pre>
  
  <p>Now this works only for Basic and Digest authentication, but not for Windows Auth (NTLM). I'll get 401 response from the server which is fine when using this authentication method, but no further communication happens.</p>
  
  <p>I also tried to add domain to "network.automatic-ntlm-auth.trusted-uris" preference, but it didn't help.</p>
  
  <p>The server's full response:</p>
  
  <pre><code>Cache-Control private
  Content-Length 0
  Date Fri, 07 Jul 2017 16:48:22 GMT
  Server Microsoft-IIS/7.5
  WWW-Authenticate Negotiate
                   NTLM
  X-AspNet-Version 2.0.50727
  X-Powered-By ASP.NET
  </code></pre>