Announcement Announcement Module
Collapse
No announcement yet.
I met LDAP: error code 17 - dn: attribute type undefined,why? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I met LDAP: error code 17 - dn: attribute type undefined,why?

    I use the code from spring-ldap-reference.pdf(1.2.1).But when I add one person,I met :LDAP: error code 17 - dn: attribute type undefined.

    The code is :
    public void create(Person person) {
    DirContextAdapter context = new DirContextAdapter();
    mapToContext(person, context);
    ldapTemplate.bind(buildDn(person), context, null);
    }
    protected Name buildDn(Person person) {
    return buildDn(person.getFullName(), person.getCompany(), person
    .getCountry());
    }

    protected Name buildDn(String fullname, String company, String country) {
    DistinguishedName dn = new DistinguishedName("dc=hinge,dc=com");
    dn.add("c", country);
    dn.add("ou", company);
    dn.add("cn", fullname);
    return dn;
    }
    protected void mapToContext(Person person, DirContextOperations context) {
    context.setAttributeValues("objectclass", new String[] { "top",
    "person" });
    context.setAttributeValue("cn", person.getFullName());

    context.setAttributeValue("dn", "");
    context.setAttributeValue("sn", person.getLastName());
    context.setAttributeValue("description", person.getDescription());
    }
    The test code is :
    public void testAdd ( ){
    Person person = new Person ();
    person.setFullName( "libingwu");
    person.setLastName( "li" );
    person.setDescription( "test");
    person.setCountry( "China" );
    person.setCompany( "hingebi");
    dao.create( person );
    }
    The exception is :
    org.springframework.ldap.InvalidAttributeIdentifie rException: [LDAP: error code 17 - dn: attribute type undefined]; nested exception is javax.naming.directory.InvalidAttributeIdentifierE xception: [LDAP: error code 17 - dn: attribute type undefined]; remaining name 'cn=libingwu, ou=hingebi, c=China, dc=hinge, dc=com'
    Caused by: javax.naming.directory.InvalidAttributeIdentifierE xception: [LDAP: error code 17 - dn: attribute type undefined]; remaining name 'cn=libingwu, ou=hingebi, c=China, dc=hinge, dc=com'
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.jav a:3054)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2931)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt x.java:2737)
    at com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:379)
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bin d(ComponentDirContext.java:277)
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.bind(PartialCompositeDirContext.java:197)
    at javax.naming.directory.InitialDirContext.bind(Init ialDirContext.java:163)
    at org.springframework.ldap.core.LdapTemplate$21.exec uteWithContext(LdapTemplate.java:985)
    at org.springframework.ldap.core.LdapTemplate.execute WithContext(LdapTemplate.java:784)
    at org.springframework.ldap.core.LdapTemplate.execute ReadWrite(LdapTemplate.java:779)
    at org.springframework.ldap.core.LdapTemplate.bind(Ld apTemplate.java:982)
    at com.hinge.UserDaoLdapImpl.create(UserDaoLdapImpl.j ava:68)
    at com.hinge.TestUserDao.testAdd(TestUserDao.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at junit.framework.TestCase.runTest(TestCase.java:154 )
    at junit.framework.TestCase.runBare(TestCase.java:127 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:478)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:344)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)

  • #2
    Try removing the line:

    Code:
    context.setAttributeValue("dn", "");
    from your mapToContext method.

    Comment

    Working...
    X