Hi there,
I tried to change the password of an ldap user from php. I tried it several ways. The closest way was the following: I made a bind with the username and password to check if it's correct. After that made a bind with a user with admin rights and wrote the following lines:
$newPassword_md5 = "{MD5}" . base64_encode(pack("H*", md5($newPassword)));
$userData = array("userPassword" => $newPassword_md5);
ldap_mod_replace($this->admin_connection, $this->user_dn, $userData);
It has written the userPassword property to the ldap user, but the password wasn't changed in fact. I tried another way. Made the replace with unicodePwd with the encoded password:
$newPassword = "\"" . $newPassword . "\"";
$len = strlen($newPassword);
for($i = 0; $i < $len; $i++) {
$newPassw .= "{$newPassword{$i}}\000";
}
$newPassword = $newPassw;
$userdata['unicodePwd'] = $newPassword;
It throwed an error message: PHP Warning: ldap_mod_replace(): Modify: Server is unwilling to perform in /var/www/ ...
Can you give me the correct way to perform the password changing?