pingidentity / ldapsdk

UnboundID LDAP SDK for Java
Other
334 stars 81 forks source link

OpenLDAP "paged results cookie is invalid" #97

Open HarlemSquirrel opened 3 years ago

HarlemSquirrel commented 3 years ago

When using SimplePagedResultsControl, OpenLDAP 2.4 returns more entries than the set page size and the next request fails with "paged results cookie is invalid".

LDAPException(resultCode=2 (protocol error), numEntries=0, numReferences=0, diagnosticMessage='paged results cookie is invalid', ldapSDKVersion=5.1.3, revision=028e004da97e22a274a4116316a73d0a90526e4b')
dirmgr commented 3 years ago

Could you provide more details about the way you're using the control? In particular:

Also, the error message is being returned by the server,, and it might be a server-side issue rather than a client-side one. I would recommend checking its logs or other diagnostic information to see if there is anything there that might help provide more information about what's happening.

HarlemSquirrel commented 3 years ago

Hi dirmgr,

I did try with both critical and non critical and got the same issue.

The failure does seem to always happen at the first request with a cookie.

Here's an excerpt of the test code I'm using to replicate the issue.

                while(true) {
                    searchRequest.setControls(new SimplePagedResultsControl(100, resumeCookie));
                    SearchResult results = conn().search(searchRequest);
                    numSearches++;
                    totalEntriesReturned += results.getEntryCount();
                    entries.addAll(results.getSearchEntries());
                    SimplePagedResultsControl responseControl =SimplePagedResultsControl.get(results);
                    if (responseControl.moreResultsToReturn())
                    {
                        resumeCookie = responseControl.getCookie();
                        System.out.println("Paged cookie: " + resumeCookie);
                    }
                    else
                    {
                        break;
                    }
                }

I've tried both connection pool and single connection and that doesn't seem to matter.

I'm going to see if I can put together an easy to replicate environment for debugging.

Thank you for the quick response!