Announcement Announcement Module
No announcement yet.
I met LDAP: error code 17 - dn: attribute type undefined,why? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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

    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 xception: [LDAP: error code 17 - dn: attribute type undefined]; remaining name 'cn=libingwu, ou=hingebi, c=China, dc=hinge, dc=com'
    Caused by: 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
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCt
    at com.sun.jndi.ldap.LdapCtx.c_bind(
    at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bin d(
    at com.sun.jndi.toolkit.ctx.PartialCompositeDirContex t.bind(
    at org.springframework.ldap.core.LdapTemplate$21.exec uteWithContext(
    at org.springframework.ldap.core.LdapTemplate.execute WithContext(
    at org.springframework.ldap.core.LdapTemplate.execute ReadWrite(
    at org.springframework.ldap.core.LdapTemplate.bind(Ld
    at com.hinge.UserDaoLdapImpl.create(UserDaoLdapImpl.j ava:68)
    at com.hinge.TestUserDao.testAdd(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De
    at java.lang.reflect.Method.invoke(
    at junit.framework.TestCase.runTest( )
    at junit.framework.TestCase.runBare( )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at )
    at junit.framework.TestSuite.runTest( 08)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(

  • #2
    Try removing the line:

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