0
我需要将新用户条目添加到我的ldap。以下是我的代码:将用户添加到ldap时Ldap错误代码32
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);
当执行这段代码,我得到以下异常尽管:
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的代码指定的例子。有人可以帮助我理解此错误或正确代码的根本原因。
我使用Apache Directory Studio从LDAP树本身获取路径。例如:另一个现有条目具有DN =“cn = newName,ou = Users,dc = wso2,dc = org”。该路径中的术语(大写/小写)可能会成为问题吗?有没有办法来验证路径? –
在基本路径上提示最新答案 – marthursson
Thanks @marthursson !!从DN中删除基本路径为我工作。 –