2010-05-28 98 views

回答

3

在PHP LDAP支持默認情況下不啓用。在編譯PHP以啓用LDAP支持時,您將需要使用--with-ldap [= DIR]配置選項。 DIR是LDAP基本安裝目錄。要啓用SASL支持,請確保使用--with-ldap-sasl [= DIR],並且系統上存在sasl.h。

0

看來你的問題仍然沒有答案,因爲你沒有選擇答案。

所以,如果你想知道如何驗證用戶身份,你可以這樣來做:

$userFound = false; 

$ds = ldap_connect('my.ldap.com'); 
if ($ds) 
{ 
    // Anonymous bind 
    ldap_bind($ds); 
    // Search the DN of the user 
    $searchRes = ldap_search($ds, 'ou=people,dc=my_company,dc=com', 'uid=your_user_uid'); 

    $info = ldap_get_entries($ds, $searchRes); 

    // If the search returned at least one result, try to bind to the server 
    // using the DN you just get, and the password provided by you user 
    if ($info['count'] < 0) 
     $userFound = ldap_bind($ds, $info[0]['dn'], $password); 

    ldap_close($ds); 
} 

var_dump($userFound); 

需要注意的是,作爲三苦說,你必須安裝LDAP。它沒有默認安裝。