ldap.php
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
Reset LDAP Password
/*
===========================================================
ldap.php Zhu Weiwei
copyright©2006-2008
Http://www.cncmm.com China. All rights Reserved.
===========================================================
*/
$u = $_request[' u '];
$op = $_request[' op '];
$NP 1 = $_request[' np1 ');
$NP 2 = $_request[' np2 ');
$an = $_request[' an '];
if (!empty ($an)) {
if (empty ($u) or empty ($op) or empty ($NP 1) or Empty ($NP 2)) {
$msg = "Some filed was empty!";
}else{
if ($NP 1! = $NP 2) {
$msg = "Confirm Password error!";
}else{
if ($op = = $np 1) {
$msg = "New password can not is same as Old password!";
}else{
$ldap _host = "domain.com";
$ldap _port = 389;
$base _dn = "dc=domain,dc=com";
$connect = @ldap_connect ($ldap _host, $ldap _port);
if (! $connect) {
$msg = "Could not connect to LDAP server";
}else{
$user _dn = sprintf ("uid=%s,ou=staff,dc=domain,dc=com", $u);
$user _pass = $op;
$bind = @ldap_bind ($connect, $user _dn, $user _pass);
if (! $bind) {
$msg = "Old password error!";
}else{
$root _dn = "cn=manager,dc=domain,dc=com";
$root _pass = ' nopa$ $w 0rd# ';
$bind = @ldap_bind ($connect, $root _dn, $root _pass);
if (! $bind) {
$msg = "Programe can not bind to LDAP server!";
}else{
$values ["UserPassword"][0] = "{MD5}". Base64_encode (Pack ("h*", MD5 ($NP 1)));
$rs = @ldap_mod_replace ($connect, $user _dn, $values);
if ($rs) {
$msg = "Password modifed success!";
}else{
$msg = "Password modifed failed!";
}
}
}
}
@ldap_close ($connect);
}
}
}
}
if (!empty ($msg)) {
Print ("
$msg
");
}
?>
http://www.bkjia.com/PHPjc/478567.html www.bkjia.com true http://www.bkjia.com/PHPjc/478567.html techarticle ldap.php! DOCTYPE HTML Public-//w3c//dtd XHTML 1.0 strict//en http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd HTML xmlns=http ://www.w3.org/1999/xhtml xml:lang=en lang=en head ti ...