2
我想使用PHP更改LDAP目錄用戶的密碼。ldap_mod_replace返回true,但密碼不變
後,我綁定到LDAP,我尋找所需的用戶與samaccount
名DN和檢索dn
:
$filter="(samaccountname=desiredname.desiredname)";
$result = ldap_search($lh, $personnel_base, $filter) or die(ldap_error($lh));
//$data = ldap_get_entries($lh, $result);
$entry = ldap_first_entry($lh, $result);
$atribute = ldap_get_attributes($lh, $entry);
然後我用ldap_mode_replace更改密碼:
$newpass = "Cevadetest123#!";
ldap_mod_replace($lh, $dn, array('userpassword' => "{MD5}".base64_encode(pack("H*",md5($newpass))))) or die(ldap_error($lh));
echo "Password changed!";
雖然我得到Password changed!
輸出,密碼保持不變。
有什麼建議嗎?
編輯:我只是注意到,屬性userpassword
確實更改,但通過LDAP登錄我必須使用舊密碼!這是什麼足球?
誰實際上綁定到LDAP?用戶綁定到LDAP實際上是否允許讀取相關用戶的密碼? – heiglandreas
@heiglandreas我找到了答案併發布了它 –