note 43081 added to function.ldap-mod-replace
| From: | frederic dot jacquot at insa-lyon dot fr | Date: | Wed, 09 Jun 2004 08:26:54 +0000 |
| Subject: | note 43081 added to function.ldap-mod-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-70615@lists.php.net to get a copy of this message | ||
Changing a user password in Active Directory.
Securely connect (using ldaps) to the Active Directory and bind using an administrator account.
In this example, $userDn contains the dn of the user I want to modify, and $ad is the Active
Directory ldaps connection)
$newPassword = "MyPassword";
$newPassword = "\"" . $newPassword . "\"";
$len = strlen($newPassword);
for ($i = 0; $i < $len; $i++)
$newPassw .= "{$newPassword{$i}}\000";
$newPassword = $newPassw;
$userdata["unicodepwd"] = $newPassword;
$result = ldap_mod_replace($ad, $userDn, $userdata);
if ($result) echo "User modified!" ;
else echo "There was a problem!";
I found it hard to get a proper encoding for the unicodepwd attribute so this piece of code might
help you ;-)
----
Manual Page -- http://www.php.net/manual/en/function.ldap-mod-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43081
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43081&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43081&report=yes
Search -- http://master.php.net/manage/user-notes.php