Java LDAP - 将组添加到用户问题 - 错误代码 53 - WILL_NOT_PERFORM
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21147625/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java LDAP - Add group to user issue - Error code 53 - WILL_NOT_PERFORM
提问by Italo St
I am trying to add an user into Active Directory.
Having in mind:
我正在尝试将用户添加到 Active Directory。
考虑到:
- Using SSL
- Certificate ok
- Password works fine
- 使用 SSL
- 证书没问题
- 密码工作正常
With out group association, the user is correctly created.
没有组关联,用户被正确创建。
When I try to associate the user to a group I get the following error:
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000209A: SvcErr: DSID-031A1021, problem 5003 (WILL_NOT_PERFORM), data 0
当我尝试将用户关联到一个组时,我收到以下错误:
javax.naming.OperationNotSupportedException: [LDAP: error code 53 - 0000209A: SvcErr: DSID-031A1021, question 5003 (WILL_NOT_PERFORM), data 0
I have used the DN and NAME group attributes but none worked. My code is:
我使用了 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
I tried LdapContext.ADD_ATTRIBUTE and LdapContext.REPLACE_ATTRIBUTE. Also, I tried to add the group with the other attributes but all situation gave me the same error.
我试过 LdapContext.ADD_ATTRIBUTE 和 LdapContext.REPLACE_ATTRIBUTE。此外,我尝试添加具有其他属性的组,但所有情况都给了我同样的错误。
Does anyone have any idea what is going on?
有谁知道发生了什么?
Cheers!
干杯!
采纳答案by Sean Hall
memberOf is a constructed attribute. You have to add the user to the group's member property, not add the group to the user's memberOf property.
memberOf 是一个构造属性。您必须将用户添加到组的成员属性中,而不是将组添加到用户的 memberOf 属性中。
回答by Italo St
The solution code is:
解决代码是:
BasicAttribute member = new BasicAttribute("member",entryDN);
Attributes atts = new BasicAttributes();
atts.put(member);
ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, atts);
Thanks Hall72215.
谢谢 Hall72215。
回答by Khalid Habib
Try to use this, it works for me
尝试使用它,它对我有用
ModificationItem[] mods = new ModificationItem[1];
String userDn="cn=user name,CN=Users,DC=domain,DC=com"
String groupDn="cn=Group Name,CN=Groups,DC=domain,DC=com"
Attribute mod =new BasicAttribute("member",userDn);
mods[0] =new ModificationItem(DirContext.ADD_ATTRIBUTE, mod);
ldapContext.modifyAttributes(groupDn, mods);