Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ldapTemplate.create创建Ldap条目时发生NameNotFoundException_Java_Ldap_Openldap_Spring Ldap - Fatal编程技术网

Java 使用ldapTemplate.create创建Ldap条目时发生NameNotFoundException

Java 使用ldapTemplate.create创建Ldap条目时发生NameNotFoundException,java,ldap,openldap,spring-ldap,Java,Ldap,Openldap,Spring Ldap,我正在创建一个应用程序,它需要使用SpringLDAP(2.0.3)和使用SpringAnnotations指定的对象目录映射在OpenLdap上添加一个新的ldap条目 我成功地使用ldapTemplate.find(…)加载了ldap条目,或者使用ldapTemplate.update(条目)进行了更新,但是我无法使用ldapTemplate.create(条目)创建新条目。我得到这个例外: javax.naming.NameNotFoundException: [LDAP: error c

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

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

javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'uid=userId,ou=users,o=org'
我的LdapTemplate配置了ldap基础:“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;
    ...
}
@Entry(objectClasses={“person”,“top”,…},base=“ou=users,o=org”)
公共最终类LdapUser扩展BaseAgregateRoot{
/**可分辨名称,自动生成*/
@身份证
私名dn;
/**用户id*/
@属性(name=“uid”)
@DnAttribute(value=“uid”,索引=1)
私有字符串uid;
...
}
Dn属性是自动生成的,并且值是正确的(uid=userId,ou=users,o=org)。但是,如果我手动构建它,并匹配baseDN(uid=userId,ou=users),则创建是可以的,但不是该条目的可分辨名称

你有什么建议来解决我的问题吗


提前感谢。

使用LDAP浏览器(如Apache Directory Studio)连接到LDAP,然后查看DIT的外观?它是否有ou=users,o=org?顺便说一句,您的baseDN不能是“id=userId,ou=users”,正如您所提到的,它可以是ou=users,o=org或仅仅是o=org。DIT包含一个baseDN:o=org,其中包含许多节点,而ou=users位于。当我写“ommitting the baseDN(uid=userId,ou=users)”时,“id=userId,ou=users”是我保留的,因此我将baseDN o=org命名为,并且只保留“id=userId,ou=users”,然后创建工作就开始了。这是公平的,因为您的LdapTemplate配置了ldap基:“o=org”。那么,您面临的问题是什么呢?我的问题是,我希望条目的完整路径为DN,所以在我的示例中为“uid=userId,ou=users,o=org”。我的条目包含“entryDN”属性,该属性使用正确的DN和完整的路径自动初始化。所以我希望能够用完整路径构建我的LdapUser对象(Java)。我使用它初始化另一个条目。可能问题是我配置了ldap库。但如果删除它,则在使用ldapTemplate.find(query().where(“uid”).is(id),LdapUser.class加载条目时会出现另一个错误==>[LDAP:错误代码32-没有这样的对象]我不是Spring专家,但我建议您在生成DN时,查找entryDN自动初始化是否有方法考虑LDAP基础。