Apache – 如何获得REMOTE_USERvariables

以前我使用IIS服务器作为PHP服务器。 目前,它是Apache

在IIS上,我可以访问variables$_SERVER ['REMOTE_USER'] ,它返回用户名和域名(例如domain \ user),但是在安装XAMPP之后,这个variables不可用。

我应该怎么做才能让这个variables重新获得?

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

终于得到它的工作! :d

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

  2. Apache24\modules文件夹复制mod_authnz_sspi.so,并将其放置在Web服务器的Apache文件夹的modules文件夹中

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

    Loadmodulee authnz_sspi_module modules/mod_authnz_sspi.so

  4. 确保以下模块未被注释

    Loadmodulee authn_core_module modules/mod_authn_core.so

    Loadmodulee authz_core_module modules/mod_authz_core.so

    PS:这两个模块都需要这个工作。

  5. 把下面的代码放到你的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> 
  6. 重新启动你的Apache服务器,并希望它应该重新启动没有任何问题。

  7. 现在为了识别用户,在php页面上使用下面的代码

    echo $ _SERVER ['PHP_AUTH_USER'];

就这样。

我在用着:

  • XAMPP控制面板3.2.1
  • APACHE 2.4
 <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> 

如果您使用ModRewrite或其他我建议你保持

 Options Indexes FollowSymLinks Includes ExecCGI 

否则你会得到一个错误

 [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可再发行,使其工作。