PHP Classes

NTLM authentication help

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  NTLM authentication help  >  (Un) Subscribe thread alerts  
Subject:NTLM authentication help
Summary:Does any one have a working example of NTLM authentication
Messages:4
Author:Raymond Dijk
Date:2007-07-10 22:32:14
Update:2007-07-11 21:05:04
 

  1. NTLM authentication help   Reply   Report abuse  
Picture of Raymond Dijk Raymond Dijk - 2007-07-10 22:32:14
Hallo,

I'm would use this class for NTLM authentication on IIS. I tried everything but didn't get it to work. This are the headers that livehttp headers in firefox gives wen logging on manualy.

I can't figure out what my credentials are ($realm and $workstation).

Could please any one help me. I'm quite desperate.

Kind regards,

Raymond

HEADERS==============================================


xxx.xxxxxxxxxx.xx/

GET / HTTP/1.1
Host: xxx.xxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Mon, 28 May 2007 15:50:53 GMT
If-None-Match: "a955f4f83fa1c71:1b59"

HTTP/1.x 401 Unauthorized
Content-Length: 1656
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:28:52 GMT
----------------------------------------------------------
xxx.xxxxxx.xx/

GET / HTTP/1.1
Host: xxx.xxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Mon, 28 May 2007 15:50:53 GMT
If-None-Match: "a955f4f83fa1c71:1b59"
Authorization: NTLM TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=

HTTP/1.x 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: NTLM TlRMTVNTUAACAAAACgAKADgAAAAFgokC8YvmacfX4BAAAAAAAAAAAIYAhgBCAAAABQLODgAAAA9TAEkAQwBUAFMAAgAKAFMASQBDAFQAUwABABAAWABSAEUARgBIAE8AUwBUAAQAFgBzAGkAYwB0AHMALgBsAG8AYwBhAGwAAwAoAFgAcgBlAGYAaABvAHMAdAAuAHMAaQBjAHQAcwAuAGwAbwBjAGEAbAAFABYAcwBpAGMAdABzAC4AbABvAGMAYQBsAAAAAAA=
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------
xxx.xxxxxxxxxx.xx/

GET / HTTP/1.1
Host: xxx.xxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
If-Modified-Since: Mon, 28 May 2007 15:50:53 GMT
If-None-Match: "a955f4f83fa1c71:1b59"
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAHoAAAAYABgAkgAAAAAAAABAAAAAIgAiAEAAAAAYABgAYgAAAAAAAAAAAAAABYIIAHIAZABpAGoAawBAAHMAaQBjAHQAcwAuAGwAbwBjAGEAbABSAGEAeQBtAG8AbgBkAFQAaAB1AGkAcwDPxJdv45VzpgAAAAAAAAAAAAAAAAAAAAAT59Uvg0Ob9pwTYClnou5+gyaf1q887Bw=

HTTP/1.x 304 Not Modified
Content-Location: http://xxx.xxxxxxxxxxx.xx/Default.htm
Last-Modified: Mon, 28 May 2007 15:50:53 GMT
Accept-Ranges: bytes
Etag: "a955f4f83fa1c71:1b59"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------
xxx.xxxxxxxxxxx.xx/xref-gw.exe/site ...

GET /xref-gw.exe/site/?docno=13&command=find&oformat=41 HTTP/1.1
Host: xxx.xxxxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Content-Type: text/html
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
Connection: close
----------------------------------------------------------
xxx.xxxxxxxxxxx.xx/web/style/defaul ...

GET /web/style/default.css HTTP/1.1
Host: xxx.xxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/css,*/*;q=0.1
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.xxxxxxxxxx.xx/xref-gw.exe/site/?docno=13&command=find&oformat=41
If-Modified-Since: Sun, 10 Sep 2006 06:54:59 GMT
If-None-Match: "4fcd678a6d4c61:1b59"

HTTP/1.x 401 Unauthorized
Content-Length: 1656
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------
xxx.xxxxxxxxxxx.xx/web/style/defaul ...

GET /web/style/default.css HTTP/1.1
Host: xxx.xxxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/css,*/*;q=0.1
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.xxxxxxxxxx.xx/xref-gw.exe/site/?docno=13&command=find&oformat=41
If-Modified-Since: Sun, 10 Sep 2006 06:54:59 GMT
If-None-Match: "4fcd678a6d4c61:1b59"
Authorization: NTLM TlRMTVNTUAABAAAAB4IIAAAAAAAAAAAAAAAAAAAAAAA=

HTTP/1.x 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: NTLM TlRMTVNTUAACAAAACgAKADgAAAAFgokCUxHve5COp4wAAAAAAAAAAIYAhgBCAAAABQLODgAAAA9TAEkAQwBUAFMAAgAKAFMASQBDAFQAUwABABAAWABSAEUARgBIAE8AUwBUAAQAFgBzAGkAYwB0AHMALgBsAG8AYwBhAGwAAwAoAFgAcgBlAGYAaABvAHMAdAAuAHMAaQBjAHQAcwAuAGwAbwBjAGEAbAAFABYAcwBpAGMAdABzAC4AbABvAGMAYQBsAAAAAAA=
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------
xxx.xxxxxxxxxx.xx/web/style/default ...

GET /web/style/default.css HTTP/1.1
Host: xxx.xxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: text/css,*/*;q=0.1
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.xxxxxxxxxx.xx/xref-gw.exe/site/?docno=13&command=find&oformat=41
If-Modified-Since: Sun, 10 Sep 2006 06:54:59 GMT
If-None-Match: "4fcd678a6d4c61:1b59"
Authorization: NTLM TlRMTVNTUAADAAAAGAAYAHoAAAAYABgAkgAAAAAAAABAAAAAIgAiAEAAAAAYABgAYgAAAAAAAAAAAAAABYIIAHIAZABpAGoAawBAAHMAaQBjAHQAcwAuAGwAbwBjAGEAbABSAGEAeQBtAG8AbgBkAFQAaAB1AGkAcwA5+1cCWoDqZAAAAAAAAAAAAAAAAAAAAACIENWMx+TnV0YQGu2EK7hoAWjnFKGw0v8=

HTTP/1.x 304 Not Modified
Last-Modified: Sun, 10 Sep 2006 06:54:59 GMT
Accept-Ranges: bytes
Etag: "4fcd678a6d4c61:1b59"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------
feeds.howardshome.com/feeds/jsfeed. ...

GET /feeds/jsfeed.aspx?uid=75046&pid=808811 HTTP/1.1
Host: feeds.howardshome.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: */*
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.xxxxxxxxxx.xx/xref-gw.exe/site/?docno=13&command=find&oformat=41

HTTP/1.x 200 OK
Cache-Control: private
Content-Length: 3499
Content-Type: text/JavaScript; charset=utf-8
Content-Encoding: deflate
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 1.1.4322
X-Compressed-By: HttpCompress
Date: Tue, 10 Jul 2007 22:26:02 GMT
----------------------------------------------------------
xxx.xxxxxxxxxx.xx/web/images/arroww ...

GET /web/images/arroww.gif HTTP/1.1
Host: xxx.xxxxxxxxxx.xx
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
Accept: image/png,*/*;q=0.5
Accept-Language: nl,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://xxx.xxxxxxxxxx.xx/xref-gw.exe/site/?docno=13&command=find&oformat=41
If-Modified-Since: Thu, 24 Apr 2003 13:07:30 GMT
If-None-Match: "0d5a7662ac31:1b59"

HTTP/1.x 304 Not Modified
Last-Modified: Thu, 24 Apr 2003 13:07:30 GMT
Accept-Ranges: bytes
Etag: "0d5a7662ac31:1b59"
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Date: Tue, 10 Jul 2007 22:29:05 GMT
----------------------------------------------------------

  2. Re: NTLM authentication help   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-11 02:02:25 - In reply to message 1 from Raymond Dijk
The realm is the Windows domain you want to authenticate. That is taken from your Windows environment. The workstation is the name of your machine in the Windows network, but I think that is not really always necessary.

  3. Re: NTLM authentication help   Reply   Report abuse  
Picture of Raymond Dijk Raymond Dijk - 2007-07-11 18:53:50 - In reply to message 2 from Manuel Lemos
Thanks for your help.

But I still can't get it to work.

Could it be a version problem of NTLM? I think that i communicate with NTLM version 2. The server I would connect to is a Windows Server 2003 with IIS.

Do you know is this can be a problem?

Other wise how can I get the realm from the requested server?

I hope you have an answer on my questions.

Kind Regards,

Raymond

  4. Re: NTLM authentication help   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-11 21:05:04 - In reply to message 3 from Raymond Dijk
As I said the realm is the Windows domain you are authenticating.

As for not working, I am not sure if it is a problem with the NTLM protocol.

I do not have access to a server with NTLM authentication. If you can provide me access to one, maybe I can check it out.