php ldap 修改,PHP修改LDAP用户密码程序_PHP教程

ldap.php

/p>

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Reset LDAP Password

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");

}

?>

User Id

uid=,ou=Staff,dc=domain,dc=cn

Old Password

New Password

Confirm Password

http://www.bkjia.com/PHPjc/478567.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478567.htmlTechArticleldap.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...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值