I get a prompt for username and password (which I do not want anyway) It always falls in the if(!$auth_header), although I follow the example exactly. Why can’t I just get the username from windows?
It cannot find the headers, it cannot find the $_SERVER variable. Although I added the domain to the safe zone.
Does my server need something extra, why are those variables not available? Do I need to do anything in windows to get those variables?
Also, how did you it before? Did you use the apache module for ntlm? Did that work?
If so, you could do a var_dump($_SERVER); to see if there are any variables set.
or var_dump($GLOBALS); it may be that Apache put it in the environment and not in the server.
How do I check if php is running as an apache module? I’m not sure about that.
And I didn’t do it before, it’s a new thing I have to create inside an intranet where I delivered a piece of php software for, this is just the next step. I’ve read about the apache ntlm module that it just isn’t any good, didn’t check that myself.
We have investigated the issue and found a solution that you can use to enable SSO on windows 7 systems.
To do it, please go to Local Security policy > Security settings > local policies > security options
Select Network security > Lan manager Authentication level and change it to “Send LM & NTLM responses”
(this is for win7 btw, I don’t know if you’re on that?)
PS. Don’t you just love this “security”? Just hide everything deep deep down in the OS so no one can find it and then we’ll call it secure.
Sure it’s secure (maybe), but it’s no longer usable, which is also pretty important! sigh </rant>
I actually saw that page and found this one in the end.
I followed these steps:
Step 1 Log into the machine as an administrator.
Step 2 Click Start, then Control Panel, then Administrative Tools.
Step 3 In the left-hand pane, expand the ‘Local Policies’ tree, and click on ‘Security Options’
Step 4 In the right-hand pane, scroll down to ‘Network Security: LAN Manger Authentication Level’ and double-click it.
Step 5 A dialog with a drop-down box will appear. Select ‘Send LM & NTLM – use NTLMv2 session security if negotiated.’
Step 6 Click ‘Ok
logged off, logged on, everything using RDP by the way, nothing changes in my variables. What should I expect to happen?
That AUTH_NAME or $_SERVER[‘HTTP_AUTHORIZATION’] should come up?
as far as i understand the server doesn’t habe to do anything. it’s up to the client to send the info. do you maybe have another client you could test this with, just to see if the principle works?
Yup, you could try those, although I still think the problem lies with the client. Not sure though.
Maybe you can install a network sniffer on the client to see what HTTP headers it’s sending to the server in the HTTP request? It should contain NTLM data in there, if not, that’s the problem.
Also note that this scheme is not an http authentication scheme - it’s a connection authentication scheme which happens to (mis-)use http status codes and headers (and even those incorrectly).
so NTLM is a classic M$ let’s pile some crap on some other crap, wrap it in duct tape, and pray it works kind of thing (like SMB, or the initial MSN messenger)
This clarified something for me. You first need to send the WWW-Authenticate: NTLM header before it responds with those!
1: C --> S GET ...
2: C <-- S 401 Unauthorized
WWW-Authenticate: NTLM
3: C --> S GET ...
Authorization: NTLM <base64-encoded type-1-message>
4: C <-- S 401 Unauthorized
WWW-Authenticate: NTLM <base64-encoded type-2-message>
5: C --> S GET ...
Authorization: NTLM <base64-encoded type-3-message>
6: C <-- S 200 Ok
I need to send an NTLM request first. So now I have this (without installing the above module): I can get the username in my script. But it always says
$auth['authorized'] == false
I’m not sure when and how it should put this to true, since the test script is clearly taking the correct login details.
When ignoring this variable. How do I get to know if this user is actually granted persmission through LDAP? I don’t have a password at all!
You need to provide your own implementation of the callback function get_ntlm_user_hash($user) which should return the MD4/Unicode hashed password of the requested $user. You can get that by doing mhash(MHASH_MD4, ntlm_utf8_to_utf16le(“password”)). You also need session_start() as the script needs to persist challenge information across http requests.
The function provided is just a mock example, you need to write your own.
As a start I would put the username and password your testing against in that array (the $userdb array, which is in the format username=>password)