Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up an LDAP connection pool in a Java EE Container?

I need to put an LDAP contextSource into my Java EE container's JNDI tree so it can be used by applications inside the container.

I'm using Spring-LDAP to perform queries against ORACLE OVD. For development, I simply set up the contextSource in the Spring xml configuration file. For production, however, I need to be able to use a JNDI lookup to grab the connection/context from the container (as suggested here: http://forum.springframework.org/showthread.php?t=35122&highlight=jndi). I'm not allowed to have access to the URL/username/pwd for the production OVD instance, so that seems to rule out putting it in a jndi.properties file.

Ideally, I'd like to have a pool of connections (just like JDBC), as my application may have many LDAP queries executing at the same time. Grabbing the object from a JNDI lookup and injecting it into my SimpleLdapTemplate seems pretty straightforward, but I'm at a loss as to how to get the connection/context/pool into the JNDI tree. Would I need to construct it and package it into a RAR? If so, what are some options for letting the operations team specify the URL/username/pwd in a way that they are not accessible to the developers?

The specific container I'm using is OAS/OC4J, though I welcome strategies that have worked on other containers as well.

like image 474
Nicholas Trandem Avatar asked Dec 02 '08 17:12

Nicholas Trandem


People also ask

What is LDAP connection pooling?

Another type of connection sharing supported by the LDAP service provider is called connection pooling. In this type of sharing, the LDAP service provider maintains a pool of (possibly) previously used connections and assigns them to a Context instance as needed.

How do you set up a connection pool?

Click Resources > JDBC > Data Sources > data_source > [Additional Properties] Connection pool properties. Click Resources > JMS->Queue connection factories-> queue_connection_factory ->[Additional Properties] Connection pool.

How does connection pool work in Java?

Connection pooling means that connections are reused rather than created each time a connection is requested. To facilitate connection reuse, a memory cache of database connections, called a connection pool, is maintained by a connection pooling module as a layer on top of any standard JDBC driver product.


1 Answers

Specifically in reference to the actual pooling of LDAP connections, if you are using the built in JNDI LDAP provider, the connections are pooled already using semantics similar to JDBC data sources where separate pools are maintained for different LDAP URLs and security properties.

When creating a JNDI DirContext, configure the property com.sun.jndi.ldap.connect.pool to be true and pooling will be enabled.

There is more information on LDAP pooling here.

Details on configuring LDAP pooling are here.

like image 61
Nicholas Avatar answered Sep 24 '22 17:09

Nicholas