[英]Steps to implement LDAP on my website using PHP
任何人都可以讓我使用PHP在我的網站上逐步解釋LDAP
默認情況下不啟用PHP中的LDAP支持。 在編譯PHP以啟用LDAP支持時,您將需要使用--with-ldap [= DIR]配置選項。 DIR是LDAP基本安裝目錄。 要啟用SASL支持,請確保使用--with-ldap-sasl [= DIR],並且系統上存在sasl.h。
首先確保你安裝了PHP的LDAP擴展,正如@YYYN建議的那樣。 要實現基於LDAP的身份驗證機制,我建議您使用Zend_Auth及其適配器進行LDAP 。 可以使用Zend_Ldap處理進一步的操作。
似乎您的問題仍未得到解答,因為您沒有選擇答案。
因此,如果您想知道如何驗證用戶,可以這樣做:
$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);
請注意,正如miku所說,您必須安裝LDAP。 默認情況下不安裝它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.