Use Windows authentication as login credentials for intranet applications

。_饼干妹妹 提交于 2019-12-03 15:01:00

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/14881997/use-windows-authentication-as-login-credentials-for-intranet-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!