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

RE: Simple Paging in OpenLdap 2.2.5



We have never seen that message.  One thing that I notice is that you use ctx.list while we are using ctx.search - maybe list doesn't support paged results?  I don't know for sure.  

I don't understand what you are using the itemCounter for - when naming.hasMore returns false then you should be able to check for the cookie, - if it is there, then there are more results, other wise there are not.

Not sure about the InitialContext creation - we create ours the second way (that works for you).

What backend are you using?  For us, ldbm does not work with paged results,  while bdb does.

Dan




-----Original Message-----
From: Jon Poulton [mailto:jon@illumining.com] 
Sent: Tuesday, February 17, 2004 11:03 AM
To: Armbrust, Daniel C.; OpenLDAP-software@OpenLDAP.org
Subject: 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();
		System.out.println(obj.toString());
	}

	//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 });
			}
		}
	}
}
..code


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
supported).
BUT! when I do its exact equivilent:

InitialLdapContext ctx = new InitialLdapContext(hashtable, null);
ctx.setRequestControls(reqCtls);

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

Whats going on???

Jon


-----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:

http://java.sun.com/products/jndi/tutorial/ldap/ext/request.html

http://forum.java.sun.com/thread.jsp?thread=319839&forum=51&message=1291218

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

http://java.sun.com/products/jndi/downloads/index.html

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.

Dan



-----Original Message-----
From: owner-openldap-software@OpenLDAP.org
[mailto:owner-openldap-software@OpenLDAP.org] On Behalf Of Pierangelo
Masarati
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.

p.

--
Pierangelo Masarati
mailto:pierangelo.masarati@sys-net.it