如何使用ZF2在ldap Active Directory(AD)中添加属性member/memberOf


How to add attribute member/memberOf in ldap Active Directory(AD) using ZF2

我尝试创建一些代码来将数据推送到Active Directory。顺便说一句,我使用的是Zend frameowk 2,对于目录服务,我使用的是Active Directory。我试图创建一些功能添加数据到活动目录,但我得到了问题。错误信息总是显示

0x35(服务器不愿执行;0000209A: SvcErr: DSID-031A1081;问题5003 (WILL_NOT_PERFORM)

这是我的代码

$ldap = new Ldap($ldap_config);
$ldap->bind();
//add member user into role     
$entry = array();         
Attribute::setAttribute($entry, 'objectclass', 'top');
Attribute::setAttribute($entry, 'objectclass', 'person');
Attribute::setAttribute($entry, 'objectclass', 'organizationalPerson');
Attribute::setAttribute($entry, 'objectclass', 'user');
Attribute::setAttribute($entry, 'cn', '123ABCD');
Attribute::setAttribute($entry, 'distinguishedname', "CN=123ABCD,OU=Staff,DC=project,DC=company,DC=go,DC=id");
Attribute::setAttribute($entry, 'dn', "CN=123ABCD,OU=Staff,DC=project,DC=company,DC=go,DC=id");
Attribute::setAttribute($entry, 'instancetype', 4);
Attribute::setAttribute($entry, 'displayName', "FebryFairuz");
Attribute::setAttribute($entry, 'sAMAccountName', "123ABCD");
Attribute::setAttribute($entry, 'employeeID', "123ABCD");
Attribute::setAttribute($entry, 'givenName', "Febry");
Attribute::setAttribute($entry, 'mail', "febryfairuz@hotmail.com");
Attribute::setAttribute($entry, 'memberOf', "CN=Default,OU=Role,DC=project,DC=company,DC=go,DC=id");
$result_update = $ldap->add("CN=123ABCD,OU=Staff,DC=project,DC=company,DC=go,DC=id", $entry);
var_dump($result_update);

如果我删除Attribute::setAttribute($entry, 'memberOf', "CN=Default,OU=Role,DC=project,DC=company,DC=go,DC=id");,它运行良好,也插入到AD。但是如果我试图添加memberOf的属性,我得到了这样的错误。我的代码有问题吗?或者我能做些什么来解决这个问题?我希望你能帮助我……

不能直接修改memberOf属性,因为它是AD中的反向链接属性。您需要做的是修改组的member属性,并将用户添加到其中。