[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Simple Paging in OpenLdap 2.2.5

Yes, Ive already tried using the booster pack. It hasnt worked so far.

My code asks for a page result control cookie after iterating thorugh the
previous NamingEnumeration, but when I try and use the PageResultsControl
created with the cookie I get:

"[LDAP: error code 53 - paged results cookie is invalid or old]"

Which obviously causes an Exception.

The loop is below if you want to have a look...

....some code
int itemCounter = pageSize;

//keep calling for pages while the last page had pageSize items in it
while (itemCounter >= pageSize)
	itemCounter = 0;
	naming = ctx.list(searchBase);
	while (naming.hasMore())
		itemCounter += 1;
		Object obj = naming.next();

	//if there are more results to come..
	if (itemCounter >= pageSize)
		// PagedResultsResponseControl contains the server cookie.
		Control[] responseControls = ctx.getResponseControls();

		// examining responseControls for a PagedResultsResponseControl
		for (int i = 0; i < responseControls.length; i++)
			if (responseControls[i] instanceof PagedResultsResponseControl)
				// create a new request control with the cookie
				// from the server's response.

				prc = new PagedResultsControl(pageSize,
					((PagedResultsResponseControl)responseControls[i]).getCookie(), true);
				ctx.setRequestControls(new Control[] { prc });

I've also found that when you do this:

InitialLdapContext ctx = new InitialLdapContext(hashtable, requestControls);

I get an exception (Exception- LDAP error code12 critical extension not
BUT! when I do its exact equivilent:

InitialLdapContext ctx = new InitialLdapContext(hashtable, null);

No Exception is thrown and I can at least get Page 1.

Whats going on???


-----Original Message-----
From: owner-openldap-software@OpenLDAP.org
[mailto:owner-openldap-software@OpenLDAP.org]On Behalf Of Armbrust,
Daniel C.
Sent: 17 February 2004 16:04
To: OpenLDAP-software@OpenLDAP.org
Subject: RE: Simple Paging in OpenLdap 2.2.5

These pages are useful if you are trying to use it from Java:



I believe you also may need the JNDI/LDAP Booster Pack from Sun:


The only other gotcha we ran into is that you have to ask for the paged
result control cookie AFTER you iterate over the first group of results.  If
you ask for it before you iterate over the results, it doesn't work.


-----Original Message-----
From: owner-openldap-software@OpenLDAP.org
[mailto:owner-openldap-software@OpenLDAP.org] On Behalf Of Pierangelo
Sent: Tuesday, February 17, 2004 9:50 AM
To: jon@illumining.com
Cc: OpenLDAP-software@OpenLDAP.org
Subject: Re: Simple Paging in OpenLdap 2.2.5

> Hi there,
> Could anyone give me an example of how to use paging with a set of
> results from OpenLdap? Version 2.2.5 is supposed to support paging
> according to the roadmap and I cant seem to get it working at all. If
> this is not the correct list to post such questions- please could you
> direct me to a more
> appropriate list.
> Any client code (in any langauge) that showed connecting to OpenLdap and
> paging through a set of results would be useful. I've already tried it
> with JNDI to no avail.

look at clients/tools/ldpasearch; you'll see hoe the control
is set, with its parameters; you can also try it out of the box.


Pierangelo Masarati