Announcement Announcement Module
No announcement yet.
LDAP Template lookup Not Coming Back Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • LDAP Template lookup Not Coming Back

    I'm trying to get the LDAP template to work for me, but without success so far.

    I have an LDAP tree with the following DN:

    DN: higrdn=testoe11,ou=onlineenrollment,ou=internal,dc =hig,dc=com

    I get using the JXplorer LDAP browser.

    I wrote a DAO to fetch this entry using the LdapTemplate lookup function. I create an LDAP DN and pass it along with an AttributesMapper. In my application context, I set the base attribute of the LdapTemplate equal to "dc=hig,dc=com".

    In my first attempt at doing this lookup, I created a List of 5 RDNs and added them to my LdapName. The result was immediate:

    org.springframework.ldap.EntryNotFoundException: Entry not found; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'higrdn=testoe11,ou=onlineenrollment,ou=internal,dc=hig,dc=com'
    Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'higrdn=testoe11,ou=onlineenrollment,ou=internal,dc=hig,dc=com'
    The AttributesMapper is never called back. The exception is thrown by the search.

    I did a search of this forum and found a thread that suggested I remove the base from the Rdn List. When I did that, the application ran for five minutes without bringing anything back.

    What am I missing? Here's the finder method I've implemented:

        public User findByUserHigRdn(String userHigRdn)
            User user = null;
            LdapName dn = null;
                List<Rdn> rdns = new ArrayList<Rdn>();
    // Per - remove base from RDN
                rdns.add(new Rdn("dc", "com"));
                rdns.add(new Rdn("dc", "hig"));
                rdns.add(new Rdn("ou", "internal"));
                rdns.add(new Rdn("ou", "onlineenrollment"));
                rdns.add(new Rdn("higrdn", userHigRdn));
                dn = new LdapName(rdns);
                logger.debug("dn: " + dn);
                AttributesMapper userMapper = new UserAttributesMapper();
                user = (User)ldapTemplate.lookup(dn, userMapper);
            catch (InvalidNameException e)
                logger.error("dn: " + dn, e);
                throw namingExceptionTranslator.translate(e);
            return user;
    Thanks for your help. - %

  • #2
    Found My Problem

    Found my problem: I had a very bad AttributeMapper implementation. I was iterating over the NamingEnumeration when I should have just been getting the values out of the Attributes. Mea culpa.