Results 1 to 3 of 3

Thread: Mallformed attribute value error

  1. #1
    Join Date
    Jul 2005
    Location
    Zagreb, Croatia
    Posts
    69

    Default Mallformed attribute value error

    Hello...

    Another ldap upset in my back yard....

    When i try to bind a new entry in my ldap, i set the values for
    "objectclass" attribute like this:

    Code:
    Vector objectClasses = new Vector(m_listOfObjectClasses.size());
    objectClasses.addAll(m_listOfObjectClasses);
    attributes.put("objectclass", objectClasses);
    where listOfObjectClasses is:
    Code:
    <property name="listOfObjectClasses">
       <list>
            <value>top</value>
            <value>account</value>
            <value>eAccount</value>
    	<value>eWebAccount</value>
        </list>
    </property>
    My existing entries all have the same "objectclass" attribute values:
    top,account,eAccount,eWebAccount

    Then the actual binding happens:
    Code:
    m_ldapTemplate.bind("uid=" + p_ldapUser.getUsername() + "," + getSearchBase(), null, attributes);
    or

    Code:
    m_ldapTemplate.bind("uid=" + p_ldapUser.getUsername(), null, attributes);
    The same error hapens:
    Code:
    2006-09-12 14:24:12,757 [DEBUG] [org.acegisecurity.ui.session.HttpSessionEventPublisher.sessionDestroyed] - [Publishing event: org.acegisecurity.ui.session.HttpSessionDestroyedEvent[source=org.apache.catalina.session.StandardSessionFacade@8ebb5a]]
    2006-09-12 14:24:12,773 [DEBUG] [org.springframework.context.support.AbstractApplicationContext.publishEvent] - [Publishing event in context [Root WebApplicationContext]: org.acegisecurity.ui.session.HttpSessionDestroyedEvent[source=org.apache.catalina.session.StandardSessionFacade@8ebb5a]]
    2006-09-12 14:24:12,804 [DEBUG] [org.springframework.web.servlet.DispatcherServlet.processHandlerException] - [Handler execution resulted in exception - forwarding to resolved error view: ModelAndView: reference to view with name 'genericControllerError'; model is {exception=org.springframework.ldap.UncategorizedLdapException: Operation failed; nested exception is javax.naming.directory.InvalidAttributeValueException: Malformed 'objectClass' attribute value; remaining name 'uid=dertda,ou=admins,ou=olpadmin,O=AMEX.HR,C=HR'}]
    org.springframework.ldap.UncategorizedLdapException: Operation failed; nested exception is javax.naming.directory.InvalidAttributeValueException: Malformed 'objectClass' attribute value; remaining name 'uid=dertda,ou=admins,ou=olpadmin,O=AMEX.HR,C=HR'
    javax.naming.directory.InvalidAttributeValueException: Malformed 'objectClass' attribute value; remaining name 'uid=dertda,ou=admins,ou=olpadmin,O=AMEX.HR,C=HR'
    	at com.sun.jndi.ldap.LdapClient.encodeAttribute(LdapClient.java:1041)
    	at com.sun.jndi.ldap.LdapClient.add(LdapClient.java:1089)
    	at com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:382)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(ComponentDirContext.java:277)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:197)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:186)
    	at javax.naming.directory.InitialDirContext.bind(InitialDirContext.java:156)
    	at org.springframework.ldap.LdapTemplate$16.executeWithContext(LdapTemplate.java:789)
    	at org.springframework.ldap.LdapTemplate.executeWithContext(LdapTemplate.java:641)
    	at org.springframework.ldap.LdapTemplate.executeReadWrite(LdapTemplate.java:636)
    	at org.springframework.ldap.LdapTemplate.bind(LdapTemplate.java:786)
    	at hr.pbzcard.olpadmin.business.dao.ldap.LdapDaoImpl.add(LdapDaoImpl.java:307)
    Ideas (Although this may not have any connection with the ldapTemplate)?
    Thank you in advance!

  2. #2
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    As you say, this is really not related to LdapTemplate.

    You need to add each Attribute value individually:
    Code:
    Attribute attr = new BasicAttribute("objectclass");
    for(Iterator iter = m_listOfObjectClasses.iterator(); iter.hasNext();){
      Object oneObjectclass = iter.next();
      attr.add(oneObjectclass);
    }
    
    Attributes attrs = new BasicAttributes();
    attrs.put(attr);
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  3. #3
    Join Date
    Jul 2005
    Location
    Zagreb, Croatia
    Posts
    69

    Default Works fine now

    You are right.
    Again.
    But, if i try your solution with

    Code:
      String oneObjectclass = (String)iter.next();
      attr.add(oneObjectclass);
    it does not work...

    Oh well,it's probably a totally different issue...

    Your help is much appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •