在没有OU过滤器的情况下搜索和修改活动目录中的用户

时间:2013-09-12 17:08:54

标签: php

//In my Config file (config.php)
   
$dn = "CN=" . $_POST['cn'] . ",OU=" . $cn . ",DC=" . $dc1. ",DC=" . $dc2;

$attributes = array("cn" , "mail" ,"sAMAccountName", "thumbnailPhoto", "url" ,  "displayName", "physicaldeliveryofficename" , "telephonenumber"    ,"mobile","ipphone","facsimiletelephonenumber","title","department");

$ad = ldap_connect($fqdn)or die("Couldn't connect to AD!");

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

$bd = ldap_bind($ad, $login_name, $password) or die("Couldn't bind to AD!");

有什么建议吗?下面是我的代码...我需要搜索域名活动目录,而不管OU结构如何,以满足未来的更改,而不是硬编码OU过滤器。

// In my update file (update.php) 

$result = ldap_mod_replace($ad, $dn, $user);
//$result = ldap_modify($ad, $dn, $user);

if($result){ 
    //echo "User modified!";
    header("Location: personal.php?update=yes");
}

ldap_unbind($ad);

此代码拒绝为所有用户更新仅适用于活动目录树中的某些用户。

0 个答案:

没有答案