Ldap error code 32 while adding user to ldap(将用户添加到 ldap 时出现 ldap 错误代码 32)
问题描述
我需要向我的 ldap 添加一个新用户条目.以下是我的代码:
I need to add a new user entry to my ldap. Following is my code:
javax.naming.Name name = new DistinguishedName("cn=" + userName +",ou=Users,dc=wso2,dc=org");
Attribute objectClass = new BasicAttribute("objectClass");
{
objectClass.add("top");
objectClass.add("inetOrgPerson");
objectClass.add("person");
objectClass.add("organizationalPerson");
}
Attributes userAttributes = new BasicAttributes();
userAttributes.put(objectClass);
userAttributes.put("cn", userName);
userAttributes.put("sn", "abctest");
userAttributes.put(ATTRIBUTE_USER_PASSWORD, password);
LdapTemplate ldapTemplate = (LdapTemplate) SpringBeanFactory
.getBean("ldapTemplate");
ldapTemplate.bind(name, null, userAttributes);
虽然在执行这段代码时出现以下异常:
Although when this piece of code is executed I get the following exception:
org.apache.cxf.interceptor.Fault: [LDAP: error code 32 - No Such Object];
nested exception is javax.naming.NameNotFoundException:
[LDAP: error code 32 - No Such Object]; remaining name 'cn=myname,ou=Users,dc=wso2,dc=org'
我正在遵循 http:///kaustuvmaji.blogspot.in/2014/12/simple-example-of-spring-ldap.html 用于代码.有人可以帮助我了解此错误的根本原因或正确的代码.
I am following the example specified at http://kaustuvmaji.blogspot.in/2014/12/simple-example-of-spring-ldap.html for the code. Can someone help me in understanding the root cause for this error or the right code.
推荐答案
这里的问题是路径 ou=Users,dc=wso2,dc=org
在你的 LDAP 树中不存在,所以你不能在那个路径上创建一个孩子.
The problem here is that the path ou=Users,dc=wso2,dc=org
doesn't exist in your LDAP tree, so you cannot create a child at that path.
如果您为 ContextSource
指定了基本路径,代码中的所有 DN 都应省略该基本路径,因为所有路径都将相对于指定的基本路径.
If you specified a base path for your ContextSource
that should be omitted from all DNs in code, as all paths will be relative to the specified base.
这篇关于将用户添加到 ldap 时出现 ldap 错误代码 32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将用户添加到 ldap 时出现 ldap 错误代码 32


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01