Posted By:
Jon_Poulton
Posted On:
Wednesday, February 11, 2004 05:19 AM
Hi there, Some of the stuff Im about to cover has been talked about here: clicky I am using OpenLdap version 2.2 and want to page through a large set of results one page at a time. OpenLdap has only recently decided to support paging with version 2.2- see an extract from their roadmap below: OpenLDAP 2.2 (released December 2003) Functional enhancements and improved scalability: "LDAP Sync"-based lightweight replication Proxy Cache Support Hierarchical Backend NS-SLAPI Support Backend Layering Access Control extensions including dynamic group support LDAPv3 extensions:
More>>
Hi there,
Some of the stuff Im about to cover has been talked about here:
clicky
I am using OpenLdap version 2.2 and want to page through a large set of results one page at a time. OpenLdap has only recently decided to support paging with version 2.2- see an extract from their roadmap below:
OpenLDAP 2.2 (released December 2003)
Functional enhancements and improved scalability:
"LDAP Sync"-based lightweight replication
Proxy Cache Support
Hierarchical Backend
NS-SLAPI Support
Backend Layering
Access Control extensions including dynamic group support
LDAPv3 extensions:
ACID extensions
Cancel Operation
Content Synchronization Operation
DIT Content Rules
Duplicate Entry Extension
***Simple Paged Results Extension***
Proxy Authorization Extension
I am using version 2.2 and I have been able to obtain the first 'page' of 5
test results from a total set of 10- but there does not appear to be any way
to retreive the next page, or any subsequent pages after the first one.
My code is similar to the example code in the other thread above and looks like
this:
PagedResultsControl prc = new PagedResultsControl(resultsPerPage);
//gets the first Page of 'n' results
Control[] controls = {prc};
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
/** My own helper method*/
InitialLdapContext ctx =
(InitialLdapContext)LdapDAOHelper.createAdminContext();
ctx.setRequestControls(controls);
/** Another helper method*/
String searchBase = LdapDAOHelper.getCoreUserBase();
/** Get the search filter from the method argument */
String filter = searchBuilder.getLdapSearchFilter();
//Run the search
names = ctx.search(searchBase, filter, search);
//get the response controls
Control[] responseControls = ctx.getResponseControls();
//examining responseControls for a PagedResultsResponseControl
//to get cookie for next page
for (int i = 0; i
< responseControls.length; i++)
{
if (responseControls instanceof PagedResultsResponseControl)
{
totalResults =
((PagedResultsResponseControl)responseControls).getResultSize();
int temp = totalResults/resultsPerPage;
totalPages = totalResults%resultsPerPage > 0 ? ++temp : temp;
if(pageNumber
<= totalPages)
{
//get the cookie
prc = new PagedResultsControl(resultsPerPage,
((PagedResultsResponseControl)responseControls).getCookie(),
Control.CRITICAL);
}
}
}
//get next page of results
The problem comes with this line:
Control[] responseControls = ctx.getResponseControls();
After calling it the array responseControls is null (so I get a NullPointerException). So there is no way to
get the cookie which is used to get the next page of results. Here is the
link to the Javadoc for the method:
clicky
What I dont understand is how paging can only "half" work? Does anyone have
any example JNDI code that has been used with OpenLDAP to successfully get
several pages of results, one after the other?
Jon
<<Less