使用ldapTemplate.create创建Ldap Entry时出现NameNotFoundException

时间:2015-07-22 10:08:10

标签: java ldap openldap spring-ldap

我正在创建一个需要在OpenLdap上添加新的ldap条目的应用程序,使用spring-ldap(2.0.3)和使用spring注释指定的对象目录映射。

我成功设法使用ldapTemplate.find(...)加载ldap条目,或者使用ldapTemplate.update(entry)进行更新,但我无法使用ldapTemplate.create(entry)创建新条目。我得到了这个例外:

javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'uid=userId,ou=users,o=org'

我的LdapTemplate配置了ldap base:" o = org"

尝试创建的LdapUser条目如下所示:

@Entry(objectClasses = { "person", "top", ... }, base = "ou=users,o=org")
public final class LdapUser extends BaseAggregateRoot<String> {

    /** distinguished name, automatically build */
    @Id
    private Name dn;

    /** user id */
    @Attribute(name = "uid")
    @DnAttribute(value = "uid", index = 1)
    private String uid;
    ...
}

自动构建Dn属性,值正确(uid = userId,ou = users,o = org)。但是如果我手动构建它,省略baseDN(uid = userId,ou = users),则创建是正常的,但不是此条目的可分辨名称。

你有什么建议可以解决我的问题吗?

提前致谢。

0 个答案:

没有答案