How can I reset a LDAP password in PHP?
I already have a connection to the LDAP Server.
views:
44answers:
1
+1
A:
Try the following code:
$dn = "uid=".$username.",dc=example,dc=com";
$newPassword = ...;
$newEntry = array('userpassword' => "{MD5}".base64_encode(pack("H*",md5($newPassword))));
if(ldap_mod_replace($ldapConnection, $dn, $newEntry))
print "<p>succeded</p>";
else
print "<p>failed</p>";
See:
Steven Paligo
2010-05-14 16:45:51
Is it always the same way to decrypt the password?
Eragonio
2010-05-14 17:07:22
I'm not sure I understand what you're asking.
Steven Paligo
2010-05-14 17:33:12
Sorry, I mean to encrypt the password. You encrypt it with md5 and then with base64.
Eragonio
2010-05-14 17:42:07
Actually there are at least five different password hashing schemes (speaking for OpenLDAP): `{CRYPT}`, `{MD5}`. `{SMD5}`. `{SHA}`, `{SSHA}`. See http://www.openldap.org/faq/data/cache/347.html, http://www.openldap.org/faq/data/cache/418.html, http://www.openldap.org/faq/data/cache/344.html
Stefan Gehrig
2010-05-14 17:58:07