title: Ldap error code 32 while adding user to ldap
body: <p>I need to add a new user entry to my ldap. Following is my code:</p>
  
  <pre><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);
  </code></pre>
  
  <p>Although when this piece of code is executed I get the following exception:</p>
  
  <pre><code> 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'
  </code></pre>
  
  <p>I am following the example specified at <a href="http://kaustuvmaji.blogspot.in/2014/12/simple-example-of-spring-ldap.html" rel="nofollow">http://kaustuvmaji.blogspot.in/2014/12/simple-example-of-spring-ldap.html</a> for the code. Can someone help me in understanding the root cause for this error or the right code.</p>