PHP - Change Active Directory Password
Join the DZone community and get the full member experience.
Join For Free
You are changing the password for ". $info[$i]["givenname"][0] .", " . $info[$i]["sn"][0] ." (" . $info[$i]["samaccountname"][0] .") to " . $_POST['user_pass'] ."\n";
$passwd1 = $_POST['user_pass'];
$userDn = $info[$i]["distinguishedname"][0];
$newPassword = $passwd1;
$newPassword = "\"" . $newPassword . "\"";
$len = strlen($newPassword);
for ($i = 0; $i < $len; $i++){
$newPassw .= "{$newPassword{$i}}\000";}
$newPassword = $newPassw;
$userdata["unicodePwd"] = $newPassword;
$result = ldap_mod_replace($ldap, $userDn , $userdata);
if ($result) echo "Your password has been changed!" ;
else echo "There was a problem changing your password, please call IT for help";
}
}
@ldap_close($ldap);
?>
PHP
Directory
Opinions expressed by DZone contributors are their own.
Comments