Ldap. php & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Strict // EN & quot; uninstall:
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'];
$ Np1 = $ _ REQUEST ['np1'];
$ Np2 = $ _ REQUEST ['np2 '];
$ An = $ _ REQUEST ['any'];
If (! Empty ($ )){
If (empty ($ u) or empty ($ op) or empty ($ np1) or empty ($ np2 )){
$ Msg = "Some filed was empty! ";
} Else {
If ($ np1! = $ Np2 ){
$ Msg = "confirm password error! ";
} Else {
If ($ op = $ np1 ){
$ Msg = "new password can not be 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 = "cocould 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 $ w0rd #';
$ 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 ($ np1 )));
$ 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 ");
}
?>