directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Sweetman <jeremy.sweet...@n8identity.com>
Subject Can't paginate with OpenLDAP
Date Tue, 27 Aug 2019 14:19:34 GMT
Hi,

I've successfully used the Apache Directory API to load in paged user data from Active Directory.
It's similar to the example code by 'oers' found in this stackoverflow question: https://stackoverflow.com/questions/17963975/apache-directory-ldap-paged-searches

Some differences I have are:
*   I'm coding it with Nashorn (Javascript running in Java)
*   I'm using the PagedResultsImpl class instead of PagedResultsDecorator
*   I'm saving the cookie as a string between calls by using a Base64 encoding of the byte[]
cookie.
*   I'm using Apache Directory API with the following maven import (The links to the version
2 javadoc on the website were broken so I stuck with version 1):
    <dependency>
        <groupId>org.apache.directory.api</groupId>
        <artifactId>api-all</artifactId>
        <version>1.0.3</version>
    </dependency>

Here's some of the important bits:

	var pageCursor = "";  /** or some Base64 encoded byte[] cookie if I'm trying to start from
where i left off last time. */
	...
	pagedSearchControl = new PagedResultsImpl();
	pagedSearchControl.setSize(pageSize);
	pagedSearchControl.setCookie(Base64.getEncoder().encodeToString(pageCursor.getBytes()));
	...
	var searchRequest = new SearchRequestImpl();
	...
	searchRequest.addControl(pagedSearchControl);
	...
	var cursor = new EntryCursorImpl(connection.search(searchRequest));
	...
	pagingResults = cursor.getSearchResultDone().getControl(PagedResults.OID);
	if (pagingResults != null){
	    nextPageCursor = Base64.getEncoder().encodeToString(pagingResults.getCookie());
	}

When run against Active Directory I can page all the users just fine. When I change my connection
to point to an OpenLDAP directory I am able to search for users just fine, EXCEPT for when
I set the page control cookie using a non-null value for pageCursor (one I got from base 64
encoding a previous call's cookie). Basically, I can't get the paged results from OpenLDAP.
I get no results and there are no exceptions.

*   What is needed in order to get OpenLDAP to page properly?
*   Am I missing something with setting up page control in Apache Directory?
*   Is paging a setting in OpenLDAP I need to turn on?

This question has also been posted on stackoverflow: https://stackoverflow.com/questions/57632585/paginating-openldap-with-apache-directory-ldap-api

Thank you,
Jeremy

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Mime
View raw message