title: cURL CMD vs PHP getting different result using --negotate
body: <p>I have hit a wall and cannot seem to find the appropriate answer on stack (or anywhere else). I am having a problem getting my cURL request via PHP to authorize properly.</p>
  
  <p><strong>The following request using cURL 7.57.0 via the command line works:</strong></p>
  
  <pre><code>curl --negotiate -u MYDOMAIN\myuser:mypass  http://myip:myport/mywebservice.svc
  </code></pre>
  
  <p><strong>When I try the code below using PHP 5.6.4 (running on Windows) with cURL v7.39.0 I get a 401.2 error:</strong></p>
  
  <pre><code>&lt;?php
  //Set vars
  $url = "http://myip:myport/mywebservice.svc"; // asmx URL of WSDL
  $un = "myuser";  //  username
  $password = "mypass"; // password
  $domain = "MYDOMAIN\\"; // domain
  
  //Set Header Array
  $headers = array(
              'Method: GET',
              'Content-Type: text/xml;charset=UTF-8',
              'User-Agent: PHP-SOAP-CURL',
              "SOAPAction: urn:MyService");
  
  //Create, Send and Output cURL Request
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);    
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
  curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NEGOTIATE); 
  curl_setopt($ch, CURLOPT_USERPWD,  $domain . $un.":".$password);
  
  $response = curl_exec($ch); 
  echo $response;
  ?&gt;
  </code></pre>
  
  <p><strong>Here is the PHP CURL Settings:</strong></p>
  
  <pre><code>cURL support =&gt; enabled
  cURL Information =&gt; 7.39.0
  Age =&gt; 3
  **Features**
  AsynchDNS =&gt; Yes
  CharConv =&gt; No
  Debug =&gt; No
  GSS-Negotiate =&gt; No
  IDN =&gt; Yes
  IPv6 =&gt; Yes
  krb4 =&gt; No
  Largefile =&gt; Yes
  libz =&gt; Yes
  NTLM =&gt; Yes
  NTLMWB =&gt; No
  SPNEGO =&gt; Yes
  SSL =&gt; Yes
  SSPI =&gt; Yes
  TLS-SRP =&gt; No
  Protocols =&gt; dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, pop3, pop3s, rtsp, scp, sftp, smtp, smtps, telnet, tftp
  Host =&gt; i386-pc-win32
  SSL Version OpenSSL/1.0.1i
  ZLib Version =&gt; 1.2.7.3
  libSSH Version =&gt; libssh2/1.4.3
  </code></pre>
  
  <p><em>For what it's worth, I am trying to connect to a web service hosted on Windows IIS using Windows Authentication with the "Negotiate" provider</em></p>
  
  <p>Does anyone have any ideas what I am doing wrong?  Is is just the difference between CURL 7.57 and curlib for PHP v7.39? </p>
  
  <p>Any other thoughts?</p>
  
  <p>Thank you so much in advance!
  Dan</p>
  
  <p>***************** EDIT ********************</p>
  
  <p>At this point, my best guess is that the CURLAUTH_NEGOTIATE in PHP curlib is simply not doing the same this as --negotiate in the cURL library I downloaded and ran separately via the CMD line! With that said, I think I will start new, more precise and clearly stated question.  Thanks to all who commented. </p>