简体   繁体   English

PHP警告:ldap_modify():修改:RDN上不允许进行该操作

[英]PHP Warning: ldap_modify(): Modify: Operation not allowed on RDN

I have the following code for modifying details in Active Directory: 我有以下代码用于修改Active Directory中的详细信息:

function updateActiveDirectory($user, $first, $last, $mail, $number, $title, $service, $team)
{
$server = "DC-1";
 $unit           = "OU=Staff,OU=Users,DC=rugby,DC=internal";
 $ds                = ldap_connect($server);
 if(!$ds)
 {
      return "Cannot connect to LDAP server";
 }
 $bind = ldap_bind($ds, "DOMAIN\Administrator", "PASSWORD");
 if(!$bind)
 {
      return "Couldn't bind to LDAP server";
 }
 ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
 $sr = ldap_search($ds, $unit, "(sAMAccountName={$user})");
 $ent= ldap_get_entries($ds, $sr);
 $userdata = array();
 $userdata["cn"][0]=$first. " ".$last;
 $userdata["sn"][0]=$last;
 $userdata["mail"][0]=$mail;
 $userdata["telephonenumber"][0]=$number;
 $userdata["company"][0]=$service;
 $userdata["department"][0]=$team;
 $userdata["title"][0]=$title;
 $name = $ent[0]["dn"];
 ldap_modify($ds, $name, $userdata);
}

I am getting Warning: 我收到警告:

ldap_modify(): Modify: Operation not allowed on RDN ldap_modify():修改:RDN上不允许进行该操作

but am not able to find anything online about this issue. 但无法在线找到有关此问题的任何信息。 What is the problem here? 这里有什么问题?

You cannot modify the CN attribute like that. 您不能像这样修改CN属性。 That attribute forms the RDN . 该属性形成RDN If you need to modify that you should use the ldap_rename() function: 如果需要修改,则应使用ldap_rename()函数:

$rdn = 'cn='.ldap_escape($first." ".$last, null, LDAP_ESCAPE_DN);
ldap_rename($ds, $ent[0]["dn"], $rdn, null, true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM