将用户添加到ldap时,ldap错误代码32 [英] Ldap error code 32 while adding user to ldap

查看:2296
本文介绍了将用户添加到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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆