Ita*_* St 10 java ldap active-directory
我正在尝试将用户添加到Active Directory中.
记住:
使用组关联,可以正确创建用户.
当我尝试将用户关联到组时,我收到以下错误:
javax.naming.OperationNotSupportedException:[LDAP:错误代码53 - 0000209A:SvcErr:DSID-031A1021,问题5003(WILL_NOT_PERFORM),数据0
我使用了DN和NAME组属性但没有一个工作.我的代码是:
ctx = getContext();
ctx.createSubcontext(entryDN,entry); // it works fine
Attribute memberOf1 = new BasicAttribute("memberOf","NAME_OF_THE_GROUP");
Attributes atts = new BasicAttributes();
atts.put(memberOf1);
ctx.modifyAttributes(entryDN, LdapContext.ADD_ATTRIBUTE, atts); // ## it doesn't work
Run Code Online (Sandbox Code Playgroud)
我尝试了LdapContext.ADD_ATTRIBUTE和LdapContext.REPLACE_ATTRIBUTE.此外,我尝试添加具有其他属性的组,但所有情况都给了我相同的错误.
有谁知道发生了什么事?
干杯!
Sea*_*all 16
memberOf是一个构造的属性.您必须将用户添加到组的成员属性,而不是将该组添加到用户的memberOf属性.
解决方案代码是:
BasicAttribute member = new BasicAttribute("member",entryDN);
Attributes atts = new BasicAttributes();
atts.put(member);
ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, atts);
Run Code Online (Sandbox Code Playgroud)
谢谢Hall72215.