我试图修改AD中的notes / info部分,并且我发现了Object类违规。任何人都可以帮忙。(也试过ldap_mod_add / ldap_mod_replace)
$userName ='username';
set_time_limit(30);
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors',1);
$ldapserver = 'server';
$ldapuser = 'user';
$ldappass = 'passowrd';
$ldaptree = "ou=Sites,dc=folder,dc=local";
$justthese = array("samaccountname", "employeeId", "mobile","info");
// connect
$ldapconn = ldap_connect($ldapserver) or die("Could not connect to LDAP server.");
if($ldapconn) {
$ldapbind = ldap_bind($ldapconn, $ldapuser, $ldappass) or die ("Error trying to bind: ".ldap_error($ldapconn));
if ($ldapbind) {
$result = ldap_search($ldapconn,$ldaptree, "(samaccountname=$userName)", $justthese) or die ("Error in search query: ".ldap_error($ldapconn));
$data = ldap_get_entries($ldapconn, $result);
//echo $ldapUserName = $data[0]["info"][0];
$userdata["info"][0] = "test test";
ldap_modify ($ldapconn, $ldaptree, $userdata);
echo ldap_error($ldapconn);
}
}
答案 0 :(得分:0)
问题在于我的DN。
改变了这一点。
ou=Sites,dc=folder,dc=local
到此,
CN=name, OU=USERS, ou=Denver, ou=Sites, dc=folder, dc=local