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

Feb*_*ruz 5 php zend-framework ldap active-directory openldap

我尝试创建一些代码将数据推送到 Active Directory 中。顺便说一句,我正在使用 Zend Framerowk 2,对于目录服务,我正在使用 Active Directory。我尝试创建一些将数据添加到 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);
Run Code Online (Sandbox Code Playgroud)

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

Cha*_*rra 6

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