【问题标题】:Java LDAP - Add group to user issue - Error code 53 - WILL_NOT_PERFORM [duplicate]Java LDAP - 将组添加到用户问题 - 错误代码 53 - WILL_NOT_PERFORM [重复]
【发布时间】:2014-01-15 20:33:56
【问题描述】:

我正在尝试将用户添加到 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。 另外,我尝试添加具有其他属性的组,但所有情况都给了我同样的错误。

有人知道发生了什么吗?

干杯!

【问题讨论】:

    标签: java active-directory ldap


    【解决方案1】:

    memberOf 是一个构造属性。您必须将用户添加到组的成员属性,而不是将组添加到用户的 memberOf 属性。

    【讨论】:

    • 可爱,它解决了我的问题!我会在几分钟后发布解决方案。
    • BasicAttribute member = new BasicAttribute("member",entryDN);属性 atts = new BasicAttributes(); atts.put(成员); ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, atts);
    • 非常感谢您的解决方案。它像任何东西一样工作:)
    【解决方案2】:

    解决方案代码为:

    BasicAttribute member = new BasicAttribute("member",entryDN);
    Attributes atts = new BasicAttributes();
    atts.put(member);
    ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, atts);      
    

    感谢 Hall72215。

    【讨论】:

    • 更短:属性 member = new BasicAttributes("member", entryDN); ctx.modifyAttributes("GROUP_DN", LdapContext.ADD_ATTRIBUTE, 成员);
    • 您应该使用最终解决方案更新您的初始问题,这样它就不会在答案中丢失,但感谢您发布!
    【解决方案3】:

    尝试使用它,它对我有用

    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);
    

    【讨论】:

    • 感谢我得到了使用此代码的解决方案
    • 我也得到了使用你的代码块的解决方案 :) 谢谢
    猜你喜欢
    • 1970-01-01
    • 2017-01-22
    • 2021-10-22
    • 1970-01-01
    • 2016-08-19
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    相关资源
    最近更新 更多