0

I wanted to Know how external LDAP is connected using JNDI configuration in TOMCAT.

My code is something like

try {
    InitialContext iniCtx = new InitialContext();
    ctx = (LdapContext) iniCtx.lookup("external/ldap/worker");
    //System.out.println("LDAP Context initialized::"+ctx);
    if(ctx!=null) {
        urlProvider=ctx.getEnvironment().get("java.naming.provider.url").toString();
    } 

} catch (NamingException ne) {                        
    throw new NamingException(ne.toString());
} 

My Context.xml in Tomcat has following entry

<Resource 
  useDataSourceFactory="true"
  name="external/ldap/worker"
  auth="Container"
  type="com.sun.jndi.ldap.LdapCtxFactory"
  java.naming.factory.initial="com.sun.jndi.ldap.LdapCtxFactory"
  java.naming.provider.url="ldap://corpt605.corporate.***.***:13891"
  java.naming.security.authentication="simple"
  java.naming.security.principal="uid=cpasysuser,ou=******,o=***.com"
  java.naming.security.credentials="*********"
/>

And my web.xml has following entry

<resource-ref>
    <description>E2k Ldap Datasource example</description>
    <res-ref-name>external/ldap/worker</res-ref-name>
    <res-type>com.sun.jndi.ldap.LdapCtxFactory</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

When I use this JNDI datasource I get following error:

08 Oct 2014 10:12:03,394 ERROR waveset.ge.commons.LdapJndiConnection_CDI:52 - getLdapCntxt::Error occured during Ldap context lookupjavax.naming.NameNotFoundException: Name [external/ldap/worker] is not bound in this Context. Unable to find [external].

What is wrong?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
annonymus
  • 9
  • 2
  • 1
    possible duplicate of [Trying to configure LDAP as JNDI Resource in Tomcat](http://stackoverflow.com/questions/13040980/trying-to-configure-ldap-as-jndi-resource-in-tomcat) – user207421 Oct 08 '14 at 07:05
  • Hi, I read that blog before, but that is for and ldap within same jvm. I am using ldap on diff jvm. So that may not help in my case. The tomcat is not accepting the resource name and hence not giving me context of ldap jndi. – annonymus Oct 08 '14 at 09:27
  • It isn't a blog, it's an SO question, and it isn't 'for an LDAP within the same JVM'. There is no such thing. – user207421 Oct 10 '14 at 01:32

0 Answers0