简体   繁体   English

NTLM身份验证在Apache / PHP中不起作用

[英]NTLM authentification is not working in Apache/PHP

So, what's the story 那是什么故事

I want to enable NTLM auth in Apache and already installed ntlm library (mod_auth_ntlm), installed necessary VS redistributable and placed following strings to httpd.conf 我想在Apache中启用NTLM身份验证,并且已经安装了ntlm库(mod_auth_ntlm),安装了必要的VS可再发行组件,并将以下字符串放置到httpd.conf中

LoadModule auth_ntlm_module modules/mod_authn_ntlm.so


<Location /test >
     AuthType NTLM
     NTLMAuth on
     NTLMAuthoritative on
     NTLMOfferBasic off
    <RequireAll>
        <RequireAny>
            Require valid-user
        </RequireAny>
    </RequireAll>
</Location>

Starting phpinfo - and there is no variables like REMOTE_USER, but ntlm library is successfully loaded 启动phpinfo-并且没有像REMOTE_USER这样的变量,但是ntlm库已成功加载

Any folder on web-server is accessible except /test folder - it just returns error 500 Apache error.log has following strings: 除/ test文件夹外,均可访问Web服务器上的任何文件夹-它仅返回错误500 Apache error.log具有以下字符串:

[Wed Feb 24 14:54:46.231132 2016] [authn_core:error] [pid 668:tid 1776] [client 10.16.66.19:53872] AH01796: AuthType NTLM configured without corresponding module

So, what's the catch? 那么,有什么收获呢? Any other possibilities? 还有其他可能性吗?

Solution found! 找到解决方案!

Still, it's not NTLM library, but SSPI (mod-authn-sspi) 不过,它不是NTLM库,而是SSPI(mod-authn-sspi)

  1. Download correct version of SSPI library (in case of Apache 2.4 it should be mod_authnz_sspi) 下载正确版本的SSPI库(对于Apache 2.4,应为mod_authnz_sspi)

  2. Unzip and put .so file into Apache /modules directory 将.so文件解压缩并将其放入Apache / modules目录

  3. Edit httpd.conf 编辑httpd.conf

LoadModule authnz_sspi_module modules/mod_authnz_sspi.so <Directory "/test"> AllowOverride None Options None Order allow,deny Allow from all AuthType SSPI SSPIAuth On SSPIAuthoritative On SSPIDomain KL Require valid-user </Directory>

  1. Create directory /test in your www folder (/test is just exemplary folder) and place following .htaccess file 在您的www文件夹中创建目录/ test(/ test仅是示例性文件夹),并将其放置在.htaccess文件之后

AuthName "authoriz" AuthType SSPI SSPIAuth On SSPIAuthoritative On require valid-user

Of course, you can change AuthName 当然,您可以更改AuthName

  1. Try following php code in the /test directory 尝试在/ test目录中遵循以下php代码

<?php $cred = explode('\\\\',$_SERVER['REMOTE_USER']); if (count($cred) == 1) array_unshift($cred, "(no domain info - perhaps SSPIOmitDomain is On)"); list($domain, $user) = $cred; echo "You appear to be user <B>$user</B><BR/>"; echo "logged into the Windows NT domain <B>$domain</B>"; ?>

Should work! 应该管用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM