【问题标题】:Spring LdapTemplate - attribute 'gidNumber' not allowed exceptionSpring LdapTemplate - 属性'gidNumber'不允许异常
【发布时间】:2012-12-14 00:53:19
【问题描述】:

我正在尝试使用 Spring LDAPTemplate 控制 OpenLDAP。

在 LDAP 中,我有组和用户组织单位。我正在尝试通过组关联将新用户绑定到 LDAP。 (通用用户帐户)所以当我尝试绑定新用户时,我还将gidNumber attiribute 放入属性对象中。但我收到这样的错误:

[LDAP: error code 65 - attribute 'gidNumber' not allowed]; nested exception is javax.naming.directory.SchemaViolationException: [LDAP: error code 65 - attribute 'gidNumber' not allowed]; remaining name 'ou=staff'

这是我迄今为止尝试过的:

DistinguishedName dn = new DistinguishedName();
dn.add("ou", "staff");
Attributes attributes = new BasicAttributes();
attributes.put("objectClass", "inetOrgPerson");
attributes.put("uid", username);
attributes.put("givenName", name);
attributes.put("gidNumber", gidNumber.toString());
attributes.put("sn", surname);
attributes.put("cn", name + " " + surname);
attributes.put("userPassword", password);
ldapTemplate.bind(dn, null, attributes);

这是我的架构:

+--> dc=ibu,dc=edu,dc=tr (5)
  ---> cn=admin
  +--> ou=group (1)
    | ---> cn=Academic
  ---> ou=guest
  +--> ou=staff (2)
    | ---> cn=John Clark
  ---> ou=student

【问题讨论】:

    标签: spring ldap jndi spring-ldap


    【解决方案1】:

    您必须添加另一个名为 posixAccount 的对象类。因为属性 gidNumber 属于这个类。所以尝试再添加一个对象类,如下所示:

    attributes.put("objectClass", "posixAccount");
    

    【讨论】:

    • 感谢您的回复;但现在我又遇到了一个例外:LDAP: error code 65 - no structural object class provided
    【解决方案2】:

    一个 LDAP 条目必须只有一个且只有一个结构对象类。不过,一些损坏的服务器确实允许多个结构对象类。添加结构对象类(要添加的对象类取决于条目的用途)。

    【讨论】:

    • 我更新了问题,添加了我的 LDAP 架构。您能否更简要地解释一下如何使用 Spring LDAP 添加此依赖项?例如,如果我想将一个用户添加到 Academic 组,我该如何表达呢?
    猜你喜欢
    • 1970-01-01
    • 2014-05-23
    • 2012-02-17
    • 2017-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-21
    • 2018-08-30
    相关资源
    最近更新 更多