2017-05-04 69 views
0

我使用這個小PHP腳本(最小[工作正常爲了證明點)驗證AD用戶用的.htaccess(Apache的2.4在Windows上)LDAP身份驗證

define('WLU_LDAP_SERV', 'ldaps://test.domain.com:636'); 
define('WLU_LDAP_BASE', 'OU=Employees,OU=UsersGroups,DC=test,DC=domain,DC=com'); 

function ldapAuthentication($username, $password) 
{ 
    $response = array(); 
    $err  = array(); 

    $filter = 'CN='.$username; 
    $dnbase = $filter . ',' . WLU_LDAP_BASE; 
    $fields = array("cn","mail","displayname"); 

    $link = @ldap_connect(WLU_LDAP_SERV); 
    $bind = @ldap_bind($link, $dnbase, $password); 
    $resl = @ldap_search($link, WLU_LDAP_BASE, $filter, $fields); 

    if ($resl) {  
     $info = @ldap_get_entries($link, $resl); 
    } 
    return $info; 
} 

我試圖複製使用.htaccess文件,但我的身份驗證失敗

AuthType Basic 
AuthBasicProvider ldap 
LDAPReferrals Off 
AuthLDAPBindAuthoritative off 
AuthLDAPURL ldaps://test.domain.com:636/OU=Employees,OU=UsersGroups,DC=test,DC=domain,DC=com 
AuthLDAPBindDN CN=someusername,OU=Employees,OU=UsersGroups,DC=test,DC=domain,DC=com 
AuthName "AD authentication" 
Require ldap-user 

相同的過程中,我得到這個

Authentication required! 

This server could not verify that you are authorized to access the URL "/". You either supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required. 

In case you are allowed to request the document, please check your user-id and password and try again. 

If you think this is a server error, please contact the webmaster. 
Error 401 

回答