Getting blank value for $_SERVER['AUTH_USER']

两盒软妹~` 提交于 2020-01-12 14:59:34

问题


I have a PHP app running on Windows 2008 server R2, which authenticates users against Active Directory using PHP's LDAP library.

As per this answer, I'm looking to use $_SERVER['AUTH_USER'], but I'm getting a blank value for it. Same for AUTH_TYPE and AUTH_PASSWORD. The variables are declared, but none of them have any value assigned to them.

I've enabled both the Basic Authentication and Windows Authentication roles (through Server Manager), but neither has solved the issue.

I'm using PHP 5.3.14, Zend Server CE and IIS 7.5.

I need to apply a single sign on solution, but without being able to fetch the currently logged in user's credentials, I'm at a loss.

Any help would be greatly appreciated.


回答1:


I got it working by disabling Anonymous Authentication in IIS, and enabling Windows Authentication (I thought Windows Authentication was already enabled, but it turns out the role was simply installed.) Now $_SERVER['AUTH_USER'] and $_SERVER['REMOTE_USER'] are populated.




回答2:


I believe the correct index for the authenticated user is $_SERVER['REMOTE_USER'].




回答3:


According to the PHP documentation, the correct index seems to be PHP_AUTH_USER.

Try using $_SERVER['PHP_AUTH_USER'].



来源:https://stackoverflow.com/questions/12098621/getting-blank-value-for-serverauth-user

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