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?