Authenticating NTLM with MS Exchange
A little while ago I discovered a script that emulated the NTLM challenge-resonse sequence in PHP – perfect for the intranet-based messenging system I was developing. Unfortunately, it didn’t actually authenticate users with the AD.
Now, it is rather hard to get a Apache server to connect directly to the domain controller, however @prajalpa on twitter came up with an excellent easily-accessable alternative – using the domain’s Exchange email server to authenticate instead. The challenge-response method is the same in this case, but only a simple socket has to be opened to connect, and the challenges can be sent in plain-text. A great article on NTLM over Exchange SMTP can be found at http://curl.haxx.se/rfc/ntlm.html#ntlmSmtpAuthentication.
@prajalpa’s script can be found here: http://pastebin.com/f5a2ba991, modified from the original article I found at http://www.iau5.com/ntlm.php.txt. I finally got it to work in the version below.