欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

怎么实现用php来修改AD域用户名的密码

程序员文章站 2022-05-10 14:18:02
...

$host = "ldap://10.100.1.10:389"; $domain = "dec.com"; $user =$_POST["username"]; $oldpswd=$_POST["oldpswd"]; $pwdtxt=$_POST["newpswrd"]; $conn = ldap_connect($host) or die("Could not connect!" ); ldap_set_option ( $conn, LDAP_OPT_PROTOCOL

$host = "ldap://10.100.1.10:389";
$domain = "dec.com";
$user =$_POST["username"];

$oldpswd=$_POST["oldpswd"];
$pwdtxt=$_POST["newpswrd"];
$conn = ldap_connect($host) or die("Could not connect!" );

ldap_set_option ( $conn, LDAP_OPT_PROTOCOL_VERSION, 3 );
ldap_set_option ( $conn, LDAP_OPT_REFERRALS, 0 );

$bd = ldap_bind($conn,$user."@".$domain,$oldpswd);

if($bd){
if(ldap_mod_replace($bd,$pwdtxt)) {
echo"succeded";
} else {
echo "failed";
}

为什么老是失败呢???