2017-05-26 97 views

回答

0

随着PHP文件中指出:http://php.net/manual/en/features.http-auth.php

<?php 
if (!isset($_SERVER['PHP_AUTH_USER'])) { 
    header('WWW-Authenticate: Basic realm="My Realm"'); 
    header('HTTP/1.0 401 Unauthorized'); 
    echo 'Text to send if user hits Cancel button'; 
    exit; 
} else { 
    echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>"; 
    echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</p>"; 
} 
?> 

当你拥有用户名/密码,您只需要让你的LDAP代码在使用这些凭证的LDAP认证用户。

另一种方法可以是使用可以使用LDAP后端来验证用户的HTTP服务器。例如,请参阅Apache的此文档:https://httpd.apache.org/docs/2.4/mod/mod_authnz_ldap.html