Announcement Announcement Module
Collapse
No announcement yet.
Lookup results with net.sf.ldaptemplate.EntryNotFoundException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lookup results with net.sf.ldaptemplate.EntryNotFoundException

    Hello all!

    I have a bit of a problem with the ldapTemplate lookup and search methods.

    This is my context:

    Code:
    <bean id="contextSource" class="net.sf.ldaptemplate.support.LdapContextSource">
    		<property name="url" value="ldap://localhost:389"/>
    		<property name="userName" value="cn=user"/>
    		<property name="base" value=" ou=admins,ou=teamadmin,O=TEAM.SI,C=SI"/>
    		<property name="password" value="password"/>
    		<property name="authenticatedReadOnly" value="true"/>
    	</bean>
    In my LDAP (v3) I have the following entry:
    Code:
    uid=admin,ou=admins,ou=teamadmin, o=TEAM.SI, c=SI
    When I try:
    Code:
    LdapUser ldapUser = (LdapUser)m_ldapTemplate.lookup("uid=" + p_username + "," + m_searchBase, mapper);
    
    //where m_searchBase== "ou=admins,ou=teamadmin,O=TEAM.SI,C=SI"
    i get the net.sf.ldaptemplate.EntryNotFoundException.
    Stack:

    Code:
    net.sf.ldaptemplate.EntryNotFoundException: Entry not found; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'uid=admin,ou=admins,ou=olpadmin,O=AMEX.HR,C=HR'
    javax.naming.NameNotFoundException: [LDAP: error code 32 - No Such Object]; remaining name 'uid=admin,ou=admins,ou=olpadmin,O=AMEX.HR,C=HR'
    	at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3013)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2934)
    	at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2740)
    	at com.sun.jndi.ldap.LdapCtx.c_getAttributes(LdapCtx.java:1294)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_getAttributes(ComponentDirContext.java:213)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:121)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.getAttributes(PartialCompositeDirContext.java:109)
    	at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:121)
    	at javax.naming.directory.InitialDirContext.getAttributes(InitialDirContext.java:116)
    	at net.sf.ldaptemplate.LdapTemplate$6.executeWithContext(LdapTemplate.java:464)
    	at net.sf.ldaptemplate.LdapTemplate.executeWithContext(LdapTemplate.java:408)
    	at net.sf.ldaptemplate.LdapTemplate.executeReadOnly(LdapTemplate.java:395)
    	at net.sf.ldaptemplate.LdapTemplate.lookup(LdapTemplate.java:461)
    Ideas?

    Thanks!

  • #2
    When you are specifying a base path in your ContextSource configuration all operations will be relative to this path, which means that you should remove the base path from the dn in your lookup.

    Comment


    • #3
      Work fine now

      Thanks rasky, it helped.
      Seems i haven't been reading the docs with enough attention
      cheers!

      Comment

      Working...
      X