We help IT Professionals succeed at work.

PHP NTLM Authentication

Hello Experts!

I need help from an expert in both PHP and NTLM to help me to find out how I can access a wsdl and get back a valid SOAP response.

I know that NTLM uses a multi-step authentication process, and all of this is new to me since up to this point I have only been using basic authentication, does anyone know if there is any way that this can be accomplished through CURL (and please, I only need responses from those that have had proven results.  I've already been all through the web and can't find a solution that works.)

Thanks a million!
Watch Question

I googled "php curl ntlm authentication" and found this comment in the PHP curl_setopt() documentation.

Looks like it's pretty straight forward as long as you have the CURL module available to PHP.

I just tested this code against my Sharepoint server from my Linux server:

  $username = 'myuser';
  $password = 'mypass';
  $url = 'http://intranet';

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");

  $output = curl_exec($ch);
  $result = curl_getinfo($ch);

  echo $result['http_code'];

Open in new window

On successful authentication I received a webpage saying the object had moved (since http://intranet is the shorthand for my LAN FQDN which hosts Sharepoint)

On failure I received a 401 response i.e. Authentication failure.

I tested this by specifying a correct/incorrect password for the user.


OMG, you are a freaking genius!  I could have never suspected that the solution would be so simple! :)