Apache - 如何获取 REMOTE_USER 变量 [英] Apache - how to get REMOTE_USER variable

查看:24
本文介绍了Apache - 如何获取 REMOTE_USER 变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之前我使用 IIS 服务器作为 PHP 服务器.目前,它是apache.

在 IIS 上,我可以访问变量 $_SERVER ['REMOTE_USER'],它返回用户名和域(例如域\用户),但在安装 XAMPP 后,此变量不可用.

我应该怎么做才能再次获得这个变量?

我的应用程序在没有互联网连接的本地网络上

解决方案

终于开始工作了!:D

  1. 从这里下载模块 https://www.apachehaus.net/modules/mod_authnz_sspi//a>(x86 用于 32 位,x64 用于 64 位 apache)

  2. Apache24\modules 文件夹中复制 mod_authnz_sspi.so 并将其放在网络服务器上 Apache 文件夹的模块文件夹中

  3. 在 httpd.conf 文件(Apache 的配置文件)下放置这行代码.尝试将其作为最后一个模块加载:

    LoadModule authnz_sspi_module modules/mod_authnz_sspi.so

  4. 确保以下模块没有被注释

    LoadModule authn_core_module modules/mod_authn_core.so

    LoadModule authz_core_module modules/mod_authz_core.so

    PS:需要上述两个模块才能工作.

  5. 将以下代码放在您的 httpd.conf 文件中

    <块引用>

    <目录path/to/your/htcdocs/folder">选项 无允许覆盖所有命令允许,拒绝所有人都允许#AuthName "SSPI 保护的地方"身份验证类型 SSPISSPIAuth 开启SSPI权威开启SSPIOffer基本开SSPIOmitDomain 开启需要有效用户</目录>

  6. 重启你的 apache servive,希望它重启后不会出现任何问题.

  7. 现在为了识别用户,在php页面上使用以下代码<块引用>

    echo $_SERVER['PHP_AUTH_USER'];

仅此而已.

我正在使用:

Previously I used the IIS server as PHP server. Currently, it is the 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.

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

  1. Download the module from here https://www.apachehaus.net/modules/mod_authnz_sspi/ (x86 for 32 bit and x64 for 64 bit apache)

  2. Copy the mod_authnz_sspi.so from Apache24\modules folder and place it in the modules folder of your Apache folder on your webserver

  3. Under the httpd.conf file (Config file for your apache) place this line of code. Try to load this as the last module:

    LoadModule authnz_sspi_module modules/mod_authnz_sspi.so

  4. 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.

  5. Place the following code in your httpd.conf file

    <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>
    

  6. Restart your apache servive and hopefully it should restart without any issues.

  7. Now in order to recognise the user , use the following code on a php page

    echo $_SERVER['PHP_AUTH_USER'];

That's all.

I'm using:

  • XAMPP Control Panel 3.2.1
  • APACHE 2.4

这篇关于Apache - 如何获取 REMOTE_USER 变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆