Use Windows authentication as login credentials fo

2020-05-28 18:08发布

I'm working on an intranet web application in PHP. Im trying to use Windows NT login credentials to logon to the application. The trouble im having here is how do i get the remote users windows username? I want to obtain the username and then check against various LDAP groups so that I can direct them to appropriate pages in my application.

I've so far tried

<?php
echo $_SERVER['REMOTE_USER'];
echo $_SERVER['PHP_AUTH_USER'];
?>

Both of them return empty values.

UPDATE: Using $_SERVER['REMOTE_ADDR'] Im able to get the IP address of the computer. Is there anyway I could get userid/username (anything unique) and use it to compare against LDAP groups? I would want to do this, when they enter the main page of the website and store a session and then use the session variable throughout the website.

2条回答
我想做一个坏孩纸
2楼-- · 2020-05-28 18:28

Not sure if you still need help with this but recently i've had to create code to log intranet users on to our site automatically using windows authentication which is run using IIS. When using windows authentication and ISS in order obtain the logged in user firstly ensure you have windows authentication enabled and anonymous disabled.

$_SERVER['AUTH_USER']; // obtain the LanID of the logged in user.

If you require more info let me know.

查看更多
神经病院院长
3楼-- · 2020-05-28 18:34

You have to send the NTLM-Authenticate headers first. After that, there should be the right user in the $_SERVER-Vars

header('WWW-Authenticate: NTLM');
echo $_SERVER['AUTH_USER'];

AFAIK this only works in InternetExporer - browsers

查看更多
登录 后发表回答