LDAP连接重置计时器

时间:2016-02-02 13:37:50

标签: ldap

我正在使用initialldapcontext创建LDAP连接。 我看到有这样的选择 jndi.ldap.read.timeout - 等待读操作的时间 jndi.ldap.connect.timeout - 等待连接操作的时间。

我有一个要求ldap连接处于活动状态,但我仍然根据计时器终止它。 例如:有三个ldap服务器,有时间5分钟。因此,一旦打开ldap连接,它必须仅激活5分钟,然后它应该终止然后重新连接。 有点像ldap会话的最大会话时间。 是否有任何标志如jndi.ldap.read.timeout或jndi.ldap.connect.timeout用于此目的。

提前致谢。

1 个答案:

答案 0 :(得分:2)

I would suggest using a connection pool. The JNDI LDAP provider documentation shows that there is a system property called com.sun.jndi.ldap.connect.pool.timeout which would do the disconnect part for you. Not the automatic reconnect, though. However, establishing a new connection should not be very expensive (unless you really need to optimize for speed/scale).

The UnboundID LDAP SDK (disclaimer: I work for UnboundID) has more flexible options. See the LDAPConnectionPool class for more details.