[英]Apache - how to get REMOTE_USER variable
Previously I used the IIS server as PHP server.以前我使用 IIS 服务器作为 PHP 服务器。 Currently, it is the apache.目前,它是 apache。
On IIS I could access to the variable $_SERVER ['REMOTE_USER']
which returns the username and domain (eg domain\\user) but after installing XAMPP this variable is not available.在 IIS 上,我可以访问变量$_SERVER ['REMOTE_USER']
,它返回用户名和域(例如域\\用户),但在安装 XAMPP 后,此变量不可用。
What I should do to get this variable get again?我应该怎么做才能再次获得这个变量?
My app is on local network with no-internet connection我的应用程序在没有互联网连接的本地网络上
Finally got it to works!终于让它工作了! :D :D
Download the module from here https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)从这里下载模块https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)
Copy the mod_authnz_sspi.so from Apache24\\modules
folder and place it in the modules folder of your Apache folder on your webserver从Apache24\\modules
文件夹中复制 mod_authnz_sspi.so 并将其放在网络服务器上 Apache 文件夹的模块文件夹中
Under the httpd.conf file (Config file for your apache) place this line of code.在 httpd.conf 文件(您的 apache 的配置文件)下放置这行代码。 Try to load this as the last module:尝试将其加载为最后一个模块:
LoadModule authnz_sspi_module modules/mod_authnz_sspi.so
Make sure that the following modules are uncommented确保以下模块没有被注释掉
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_core_module modules/mod_authz_core.so
PS: both the above modules are required for this to work. PS:需要上述两个模块才能工作。
Place the following code in your httpd.conf file将以下代码放在您的 httpd.conf 文件中
<Directory "path/to/your/htcdocs/folder"> Options None AllowOverride All Order allow,deny Allow from all #AuthName "SSPI Protected Place" AuthType SSPI SSPIAuth On SSPIAuthoritative On SSPIOfferBasic On SSPIOmitDomain On Require valid-user </Directory>
Restart your apache servive and hopefully it should restart without any issues.重新启动您的 apache servive,希望它可以重新启动而不会出现任何问题。
echo $_SERVER['PHP_AUTH_USER']; echo $_SERVER['PHP_AUTH_USER'];
That's all.就这样。
I'm using:我正在使用:
<Directory "path/to/your/htcdocs/folder">
Options None
AllowOverride All
Order allow,deny
Allow from all
#AuthName "SSPI Protected Place"
AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain On
Require valid-user
</Directory>
If you use ModRewrite or other I suggest you to keep如果您使用 ModRewrite 或其他,我建议您保留
Options Indexes FollowSymLinks Includes ExecCGI
otherwise you'll get an error like否则你会得到这样的错误
[rewrite:error]: Options FollowSymLinks and SymLinksIfOwnerMatch are both off, so the RewriteRule directive is also forbidden due to its similar ability to circumvent directory restrictions
如果 Apache 已经对用户进行了实际身份验证,您只能访问远程用户,请检查apache auth howto 。
我为此挣扎了很长时间,结果我必须安装 VC 可再发行组件才能使其工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.