PHP修改LDAP用户密码程序_PHP教程
/p>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
dt{
font-weight: bold;
}
/*
===========================================================
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['an'];
if(!empty($an)){
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 = "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$$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
");}
?>
推荐阅读
-
PHP修改LDAP用户密码程序_PHP教程
-
修改获取验证码图片到本地的PHP程序_PHP教程
-
暴破FTP用户名和密码(PHP练手作品)_PHP教程
-
apmserv中修改mysql的root与phpmyadmin密码方法介绍_PHP教程
-
PHP《个人管理系统》之修改密码_PHP教程
-
暴破FTP用户名和密码(PHP练手作品)_PHP教程
-
PHP中 上运行 root 用户才可以运行的外部程序_PHP教程
-
XAMPP修改mysql的root密码phpmyadmin无法登陆_PHP教程
-
php记住用户名和密码实现代码(cookie)_PHP教程
-
php带密码功能并下载远程文件保存本地指定目录 修改加强版_PHP教程