The LDAP SDK will definitely let you reuse a simple paged results cookie
across multiple connections, but whether or not the server will support
it is another matter, and that's dependent on the server's simple paged
results control implementation. It will work in the UnboundID Directory
Server, but given that you are occasionally running into an error when
trying it against Active Directory (at least, I assume from the error
message that you're using Active Directory) that it may not be supported
in that server.
If you're going to use a simple paged results control against a server
that you don't know supports using a cookie across multiple connections,
then it would be safest to check out a connection from the pool, use
that connection to retrieve all pages of results, and then release that
connection back to the pool.
Neil Wilson
On 08/08/2016 03:09 PM, Sergey Klyushin wrote:
> 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
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
> What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
> patterns at an interface-level. Reveals which users, apps, and protocols are
> consuming the most bandwidth. Provides multi-vendor support for NetFlow,
> J-Flow, sFlow and other flows. Make informed decisions using capacity
> planning reports. http://sdm.link/zohodev2dev
>
>
>
> _______________________________________________
> ldap-sdk-discuss mailing list
> lda...@li...
> https://lists.sourceforge.net/lists/listinfo/ldap-sdk-discuss
>
|