I have an application that is using Spring LDAP 1.3.1. It is creating the LdapTemplate in a Spring context at startup, passing it in to my application. The LDAP string I am connecting to is in reality a VIP appliance with multiple Active Directory servers behind it.
The application is used to create a group hierarchy, and does so in several steps. First, it creates any new groups, then removes any deleted groups, then updates and changed groups, and finally it updates the parent of any new or moved groups.
In that last step, in order to do the move, I have to look up the group, then look up it's parent, and finally update the Member list of the parent to remove the child.
Here is where the problem starts. Every so often, but not every time, I have a run in which the group is added but when the code tries to set the parent, it fails because the new group isn't there yet. I believe what is happening is that Spring LDAP is reconnecting on each call, and because I am going through a VIP and the AD server is round-robin'ed, I think the newly added group hasn't replicated, so selecting the group returns null and my parent update fails. Basically I think I am running into a race condition with AD replication.
So, long explanation short: Does Spring LDAP 1.3.1, and in particular the LdapTemplate
, create a new connection each time, or am I misunderstanding how it works? Is there a way to make it use a pooled connection, either by configuration of the LdapTemaplate
or by setting com.sun.jndi.ldap.connect.pool
? If I used only one connection for the entire application run, it should solve the replication (if that is what's occuring) problem in that I would be stuck to one AD server and not bouncing around.