Java LDAP – 将组添加到用户问题 – 错误代码53 – WILL_NOT_PERFORM
我正在尝试将用户添加到Active Directory中。
记住:
- 使用SSL
- 证书好
- 密码工作正常
使用组关联,可以正确创建用户。
当我尝试将用户关联到组时,我收到以下错误:
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
我尝试了LdapContext.ADD_ATTRIBUTE和LdapContext.REPLACE_ATTRIBUTE。 此外,我尝试添加具有其他属性的组,但所有情况都给了我相同的错误。
有谁知道发生了什么事?
干杯!
memberOf是一个构造的属性。 您必须将用户添加到组的成员属性,而不是将该组添加到用户的memberOf属性。
解决方案代码是:
BasicAttribute member = new BasicAttribute("member",entryDN); Attributes atts = new BasicAttributes(); atts.put(member); ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, atts);
谢谢Hall72215。
尝试使用它,它适合我
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);
- 在ssl(ldaps)的支持下连接活动目录
- Java LDAP – 确定给定组中的用户是否?
- 每次从Ldap连接池返回新连接时
- 校验和失败:Kerberos / Spring / Active Directory(2008)
- 使用Java查找简单的Active Directory信息
- Java SSO:针对Active Directory的Kerberos身份validation
- Java SimpleDateFormat总是返回1月份的月份
- 具有错误的Active Directory Ldap凭据的会话/ Redis序列化错误的Spring启动
- 使用LDAP / Java启用Active Directory用户