Hello Cédric, The reason I want to do is as follows: I am facing the problem already expressed in https://issues.apache.org/bugzilla/show_bug.cgi?id=33774 I see that the bug status shows as Fixed, however I still get the same Issue on the Stack mentioned earlier.
Hence what I have done is that I have already extended the JNDIRealm class (CustomJNDIRealm) to disconnect as soon as authentication is successful. (ref: http://stackoverflow.com/questions/10911897/tomcat-7-0-14-ldap-authentication) public class CustomJNDIRealm extends JNDIRealm { @Override public Principal authenticate(String username, String credentials) { Principal principal = super.authenticate(username, credentials); if (context != null) { close(context); } return principal; } } Have tested this and I see it to be working great except a small problem. After tomcat starts successfully and remains idle i.e let's say there is no user who logs in (gets authenticated) for 5-10 mins...I face the same issue as mentioned in the above bug. This is because the initial connection to the LDAP exists and the above overridden authenticate () doesn't get called. Hence I want to prevent the initial connection started by tomcat to LDAP as well. I am looking for some good way of doing this only on tomcat start-up and not all other the times. What I am not able to understand is why Tomcat doesn't allow configurable parameters to either select / deselect the Realm connections on startup. Thanks -----Original Message----- From: Cédric Couralet [mailto:cedric.coura...@gmail.com] Sent: Wednesday, February 20, 2013 10:57 AM To: Tomcat Users List Subject: Re: Question regarding JNDIRealm - tomcat 6.0.35 2013/2/19 Tanmoy Chatterjee <tanmoy.chatter...@nxp.com>: > Hello, > Technical Stack: Apache Tomcat v 6.0.35 OS : RHEL 5.3 64 bits java > version "1.6.0_18" 32 bits > > I am using Realm className="org.apache.catalina.realm.JNDIRealm" for > connecting to LDAP. > > Is there any configuration to prevent the default connection to LDAP > happening on Tomcat-Start. > If I have to write my own code for doing this which method should I be > overriding? > Hello, By pure curiosity, why would you want that? The validation happens in the start method of JNDIRealm : // Validate that we can open our connection try { open(); } catch (NamingException e) { throw new LifecycleException(sm.getString("jndiRealm.open"), e); } My first attempt was to override this method in a custom Class which inherits from JNDIRealm. This obviously can't work short of rewriting the complete call to super.start(). Or, but I didn't test nor do i know if it is good (or even valid) java, you could try by overriding this method like that : @Override public void start() throws LifecycleException { ((RealmBase)this).start(); } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org