duffymo
Oct 25th, 2006, 09:22 AM
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,d c=hig,dc=com'
Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'higrdn=testoe11,ou=onlineenrollment,ou=internal,d c=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;
try
{
List<Rdn> rdns = new ArrayList<Rdn>();
// Per http://forum.springframework.org/showthread.php?t=28467&highlight=lookup - 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. - %
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,d c=hig,dc=com'
Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'higrdn=testoe11,ou=onlineenrollment,ou=internal,d c=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;
try
{
List<Rdn> rdns = new ArrayList<Rdn>();
// Per http://forum.springframework.org/showthread.php?t=28467&highlight=lookup - 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. - %