[ldap-sdk-discuss] LDAPConnection pool and paged search
A Java-based LDAP API
Brought to you by:
dirmgr,
kennethleo
From: Sergey K. <skl...@op...> - 2016-08-08 20:11:19
|
Hello, Can I use LDAPConnectionPool for paged search (or other search requests that uses cookie returned from the LDAP server)? It works for me most of the time, but once in a while I get error LDAPSearchException(resultCode=12 (unavailable critical extension), numEntries=0, numReferences=0, errorMessage='00000057: LdapErr: DSID-0C090797, comment: Error processing control, data 0, v23f0 ') at com.unboundid.ldap.sdk.LDAPConnection.search(LDAPConnection.java:3658) at com.unboundid.ldap.sdk.AbstractConnectionPool.search(AbstractConnectionPool.java:2020) I believe it happens, because new connection is used with cookie returned from previous call. I can see that new port is used in search request. My code is something like this: private LDAPConnection createNewLDAPConnection(String host, int port, boolean useSSL) throws LDAPException { LDAPConnectionOptions ldapConnectionOptions = new LDAPConnectionOptions(); ldapConnectionOptions.setAutoReconnect(true); ldapConnectionOptions.setUseKeepAlive(true); ldapConnectionOptions.setUseTCPNoDelay(true); ldapConnectionOptions.setUseSynchronousMode(true); ldapConnectionOptions.setFollowReferrals(false); ldapConnectionOptions.setResponseTimeoutMillis(0); SocketFactory sf = null; LDAPConnection ldapConnection = new LDAPConnection(sf, ldapConnectionOptions, host, port); if (!StringsUtils.isBlank(m_bindUser) && !StringsUtils.isBlank(m_bindPassword)) { ldapConnection.bind(m_bindUser, m_bindPassword); } return ldapConnection; } LDAPConnection ldapConnection = createNewLDAPConnection(m_prevConnectedUrl); m_connectionPool = new LDAPConnectionPool(ldapConnection, 3); ...... // do search. Called while getting back results with PagedControl protected SearchResult doSearch(String parentPrefix, SearchRequest searchRequest, Control[] controls) { ..... if (controls != null) { searchRequest.setControls(controls); // Paged control with cookie from previous response } searchResult = m_connectionPool.search(searchRequest); } I can see that most of the time searchResult = m_connectionPool.search(searchRequest); succeeds, but at some moment fails with LDAPSearchException(resultCode=12 (unavailable critical extension), numEntries=0, numReferences=0, errorMessage='00000057: LdapErr: DSID-0C090797, comment: Error processing control, data 0, v23f0 ') at com.unboundid.ldap.sdk.LDAPConnection.search(LDAPConnection.java:3658) at com.unboundid.ldap.sdk.AbstractConnectionPool.search(AbstractConnectionPool.java:2020) Looks like it fails, because call comes from different port (another connection) Am I right? What would you suggest? Should I use for paged searches (and other searches that use cookies) dedicated connection? Something like LDAPConnection connection = m_connectionPool.getConnection(); While (have results) { connection.search(); // with updated cookie in paged search contro } Should I release connection? Thanks in advance, Sergey |