簡體   English   中英

將用戶添加到 ldap 時出現 LDAP 錯誤代碼 32

[英]Ldap error code 32 while adding user to ldap

我需要向我的 ldap 添加一個新用戶條目。 以下是我的代碼:

     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 中指定的示例代碼。 有人可以幫助我了解此錯誤的根本原因或正確的代碼。

這里的問題是路徑ou=Users,dc=wso2,dc=org不存在於您的 LDAP 樹中,因此您無法在該路徑上創建子項。

如果您為ContextSource指定了應該從代碼中的所有 DN 中省略的基本路徑,因為所有路徑都將相對於指定的基本路徑。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM