如何使用 ZF2 在 ldap Active Directory(AD) 中添加属性 member/memberOf
How to add attribute member/memberOf in ldap Active Directory(AD) using ZF2
我试图创建一些用于将数据推送到 Active Directory 的代码。顺便说一句,我使用的是 Zend Framerowk 2,对于目录服务,我使用的是 Active Directory。我试图创建一些功能来将数据添加到 Active Directory 中,但我遇到了问题。错误信息总是显示
Error Messages
0x35 (Server is unwilling to perform; 0000209A: SvcErr: DSID-031A1081,
problem 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
属性并将用户添加到该组。
我试图创建一些用于将数据推送到 Active Directory 的代码。顺便说一句,我使用的是 Zend Framerowk 2,对于目录服务,我使用的是 Active Directory。我试图创建一些功能来将数据添加到 Active Directory 中,但我遇到了问题。错误信息总是显示
Error Messages
0x35 (Server is unwilling to perform; 0000209A: SvcErr: DSID-031A1081, problem 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
属性并将用户添加到该组。