You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Daniel Fisher <df...@vt.edu> on 2011/06/28 18:58:42 UTC

Paged Results Control

Can anyone provide some sample code for using the paged results control?
This is basically what I'm doing now:

    PagedResultsImpl prc = new PagedResultsImpl();
    prc.setCritical(true);
    prc.setSize(5);

    SearchRequest request = new SearchRequestImpl();
    request.setScope(SearchScope.SUBTREE);
    request.setBase(new Dn("dc=vt,dc=edu"));
    request.setFilter("(uid=*)");
    request.addAllControls(new Control[] {prc, });

OpenLDAP is reporting:

conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged results
control value is absent

Thanks.

--Daniel Fisher

Re: Paged Results Control

Posted by Daniel Fisher <df...@vt.edu>.
On Thu, Jun 30, 2011 at 9:56 AM, Kiran Ayyagari <ka...@apache.org>wrote:

> no, this control is supported but you jut need to set the system
> property 'default.controls' to load the controls
> e.x System.setProperty(
> StandaloneLdapApiService.DEFAULT_CONTROLS_LIST,
>
> "org.apache.directory.shared.ldap.codec.controls.search.pagedSearch.PagedResultsFactory"
> );
>
> Take a look at the code present in FrameworkRunner (starting from line 92)
>
> P.S:- we know this is kind of weird to set settings to load but we
> were trying to strike a balance between OSGi and standalone usage of
>        the server and its API, so this mandatory step for now
>
>
Thanks. That did the trick.

--Daniel Fisher

Re: Paged Results Control

Posted by Kiran Ayyagari <ka...@apache.org>.
On Thu, Jun 30, 2011 at 7:07 PM, Daniel Fisher <df...@vt.edu> wrote:
> It's likely that I'm just coding it wrong since there aren't any docs or
> samples that I can find.
> This code successfully sends the control to the LDAP:
>
>    PagedResultsImpl pri = new PagedResultsImpl();
>    pri.setCritical(true);
>    pri.setSize(1);
>    PagedResultsDecorator prd = new
> PagedResultsDecorator(LdapApiServiceFactory.getSingleton(), pri);
>
>    SearchRequest request = new SearchRequestImpl();
>    request.setScope(SearchScope.SUBTREE);
>    request.setBase(new Dn("dc=vt,dc=edu"));
>    request.setFilter("(uid=*)");
>    request.addAllControls(new Control[] {prd, });
>
> However, I can't get the cookie out of the response. The returned control is
> of type OpaqueControl, which seems to indicate that the codec service
> doesn't support this control.
>
no, this control is supported but you jut need to set the system
property 'default.controls' to load the controls
e.x System.setProperty(
StandaloneLdapApiService.DEFAULT_CONTROLS_LIST,
"org.apache.directory.shared.ldap.codec.controls.search.pagedSearch.PagedResultsFactory"
);

Take a look at the code present in FrameworkRunner (starting from line 92)

P.S:- we know this is kind of weird to set settings to load but we
were trying to strike a balance between OSGi and standalone usage of
        the server and its API, so this mandatory step for now

> --Daniel Fisher
>
> On Wed, Jun 29, 2011 at 9:15 AM, Pierre-Arnaud Marcelot <pa...@marcelot.net>wrote:
>
>> Actually this is a little more complex...
>>
>> Initially Studio was only based on JNDI and some of its APIs have been
>> spread all over the place.
>> When, we decided to include the LDAP API and offer the choice to select the
>> type of network provider (either JNDI or Apache Directory LDAP API), we
>> evaluated the impact on the existing code.
>> It was huge... And we decided to wrap/convert a few elements of the LDAP
>> API to the JNDI API, as a first step at least...
>>
>> This is especially true for the controls interface which is present in a
>> significant number of classes in Studio.
>>
>> This is why you're not finding a direct reference to the PagedResultsImpl
>> class in Studio's code. Controls are converted from and to JNDI controls as
>> OpaqueControl instances in the convertControls() methods of the
>> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper
>> class.
>>
>> We use the JNDI PagedResultsControl in the
>> org.apache.directory.studio.connection.core.StudioPagedResultsControl class
>> where it's wrapped.
>>
>> I'm going to test your code on my OpenLDAP server to see if I get the same
>> results.
>>
>> Regards,
>> Pierre-Arnaud
>>
>> On 29 juin 2011, at 14:28, Daniel Fisher wrote:
>>
>> > I'm testing OpenLDAP 2.4.23 with bdb. Paged results work fine with JNDI
>> and
>> > JLDAP, so I'm confident the server is configured correctly. I glanced at
>> the
>> > studio code, but I didn't see anything that wasn't using or delegating to
>> a
>> > JNDI PagedResultsControl. Can you point me to some source that uses
>> > org.apache.directory.shared.ldap.model.message.controls.PagedResultsImpl
>> > ? Thanks.
>> >
>> > --Daniel Fisher
>> >
>> > On Wed, Jun 29, 2011 at 3:02 AM, Pierre-Arnaud Marcelot <pa@marcelot.net
>> >wrote:
>> >
>> >> Hi Daniel,
>> >>
>> >> Studio's current trunk embeds the LDAP API as a replacement for JNDI
>> (you
>> >> can select the one you want on a connection basis).
>> >> I've tested a Paged Search using it on an OpenLDAP 2.4.24 server and it
>> >> worked fine.
>> >> It showed me the required number of results and I was able to move
>> through
>> >> pages.
>> >>
>> >> Although, it didn't work on all database backends, like the "cn=config"
>> >> database for instance.
>> >> It appears only "bdb" and "hdb" database backends support this control.
>> [1]
>> >>
>> >> Which database backend are you using for your "dc=vt,dc=edu" database  ?
>> >>
>> >> Regards,
>> >> Pierre-Arnaud
>> >>
>> >> [1] —
>> http://www.openldap.org/lists/openldap-software/200402/msg00508.html
>> >>
>> >>
>> >> On 28 juin 2011, at 18:58, Daniel Fisher wrote:
>> >>
>> >>> Can anyone provide some sample code for using the paged results
>> control?
>> >>> This is basically what I'm doing now:
>> >>>
>> >>>   PagedResultsImpl prc = new PagedResultsImpl();
>> >>>   prc.setCritical(true);
>> >>>   prc.setSize(5);
>> >>>
>> >>>   SearchRequest request = new SearchRequestImpl();
>> >>>   request.setScope(SearchScope.SUBTREE);
>> >>>   request.setBase(new Dn("dc=vt,dc=edu"));
>> >>>   request.setFilter("(uid=*)");
>> >>>   request.addAllControls(new Control[] {prc, });
>> >>>
>> >>> OpenLDAP is reporting:
>> >>>
>> >>> conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged
>> results
>> >>> control value is absent
>> >>>
>> >>> Thanks.
>> >>>
>> >>> --Daniel Fisher
>> >>
>> >>
>>
>>
>



-- 
Kiran Ayyagari

Re: Paged Results Control

Posted by Daniel Fisher <df...@vt.edu>.
It's likely that I'm just coding it wrong since there aren't any docs or
samples that I can find.
This code successfully sends the control to the LDAP:

    PagedResultsImpl pri = new PagedResultsImpl();
    pri.setCritical(true);
    pri.setSize(1);
    PagedResultsDecorator prd = new
PagedResultsDecorator(LdapApiServiceFactory.getSingleton(), pri);

    SearchRequest request = new SearchRequestImpl();
    request.setScope(SearchScope.SUBTREE);
    request.setBase(new Dn("dc=vt,dc=edu"));
    request.setFilter("(uid=*)");
    request.addAllControls(new Control[] {prd, });

However, I can't get the cookie out of the response. The returned control is
of type OpaqueControl, which seems to indicate that the codec service
doesn't support this control.

--Daniel Fisher

On Wed, Jun 29, 2011 at 9:15 AM, Pierre-Arnaud Marcelot <pa...@marcelot.net>wrote:

> Actually this is a little more complex...
>
> Initially Studio was only based on JNDI and some of its APIs have been
> spread all over the place.
> When, we decided to include the LDAP API and offer the choice to select the
> type of network provider (either JNDI or Apache Directory LDAP API), we
> evaluated the impact on the existing code.
> It was huge... And we decided to wrap/convert a few elements of the LDAP
> API to the JNDI API, as a first step at least...
>
> This is especially true for the controls interface which is present in a
> significant number of classes in Studio.
>
> This is why you're not finding a direct reference to the PagedResultsImpl
> class in Studio's code. Controls are converted from and to JNDI controls as
> OpaqueControl instances in the convertControls() methods of the
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper
> class.
>
> We use the JNDI PagedResultsControl in the
> org.apache.directory.studio.connection.core.StudioPagedResultsControl class
> where it's wrapped.
>
> I'm going to test your code on my OpenLDAP server to see if I get the same
> results.
>
> Regards,
> Pierre-Arnaud
>
> On 29 juin 2011, at 14:28, Daniel Fisher wrote:
>
> > I'm testing OpenLDAP 2.4.23 with bdb. Paged results work fine with JNDI
> and
> > JLDAP, so I'm confident the server is configured correctly. I glanced at
> the
> > studio code, but I didn't see anything that wasn't using or delegating to
> a
> > JNDI PagedResultsControl. Can you point me to some source that uses
> > org.apache.directory.shared.ldap.model.message.controls.PagedResultsImpl
> > ? Thanks.
> >
> > --Daniel Fisher
> >
> > On Wed, Jun 29, 2011 at 3:02 AM, Pierre-Arnaud Marcelot <pa@marcelot.net
> >wrote:
> >
> >> Hi Daniel,
> >>
> >> Studio's current trunk embeds the LDAP API as a replacement for JNDI
> (you
> >> can select the one you want on a connection basis).
> >> I've tested a Paged Search using it on an OpenLDAP 2.4.24 server and it
> >> worked fine.
> >> It showed me the required number of results and I was able to move
> through
> >> pages.
> >>
> >> Although, it didn't work on all database backends, like the "cn=config"
> >> database for instance.
> >> It appears only "bdb" and "hdb" database backends support this control.
> [1]
> >>
> >> Which database backend are you using for your "dc=vt,dc=edu" database  ?
> >>
> >> Regards,
> >> Pierre-Arnaud
> >>
> >> [1] —
> http://www.openldap.org/lists/openldap-software/200402/msg00508.html
> >>
> >>
> >> On 28 juin 2011, at 18:58, Daniel Fisher wrote:
> >>
> >>> Can anyone provide some sample code for using the paged results
> control?
> >>> This is basically what I'm doing now:
> >>>
> >>>   PagedResultsImpl prc = new PagedResultsImpl();
> >>>   prc.setCritical(true);
> >>>   prc.setSize(5);
> >>>
> >>>   SearchRequest request = new SearchRequestImpl();
> >>>   request.setScope(SearchScope.SUBTREE);
> >>>   request.setBase(new Dn("dc=vt,dc=edu"));
> >>>   request.setFilter("(uid=*)");
> >>>   request.addAllControls(new Control[] {prc, });
> >>>
> >>> OpenLDAP is reporting:
> >>>
> >>> conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged
> results
> >>> control value is absent
> >>>
> >>> Thanks.
> >>>
> >>> --Daniel Fisher
> >>
> >>
>
>

Re: Paged Results Control

Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
Actually this is a little more complex...

Initially Studio was only based on JNDI and some of its APIs have been spread all over the place.
When, we decided to include the LDAP API and offer the choice to select the type of network provider (either JNDI or Apache Directory LDAP API), we evaluated the impact on the existing code.
It was huge... And we decided to wrap/convert a few elements of the LDAP API to the JNDI API, as a first step at least...

This is especially true for the controls interface which is present in a significant number of classes in Studio.

This is why you're not finding a direct reference to the PagedResultsImpl class in Studio's code. Controls are converted from and to JNDI controls as OpaqueControl instances in the convertControls() methods of the org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper class.

We use the JNDI PagedResultsControl in the org.apache.directory.studio.connection.core.StudioPagedResultsControl class where it's wrapped.

I'm going to test your code on my OpenLDAP server to see if I get the same results.

Regards,
Pierre-Arnaud 

On 29 juin 2011, at 14:28, Daniel Fisher wrote:

> I'm testing OpenLDAP 2.4.23 with bdb. Paged results work fine with JNDI and
> JLDAP, so I'm confident the server is configured correctly. I glanced at the
> studio code, but I didn't see anything that wasn't using or delegating to a
> JNDI PagedResultsControl. Can you point me to some source that uses
> org.apache.directory.shared.ldap.model.message.controls.PagedResultsImpl
> ? Thanks.
> 
> --Daniel Fisher
> 
> On Wed, Jun 29, 2011 at 3:02 AM, Pierre-Arnaud Marcelot <pa...@marcelot.net>wrote:
> 
>> Hi Daniel,
>> 
>> Studio's current trunk embeds the LDAP API as a replacement for JNDI (you
>> can select the one you want on a connection basis).
>> I've tested a Paged Search using it on an OpenLDAP 2.4.24 server and it
>> worked fine.
>> It showed me the required number of results and I was able to move through
>> pages.
>> 
>> Although, it didn't work on all database backends, like the "cn=config"
>> database for instance.
>> It appears only "bdb" and "hdb" database backends support this control. [1]
>> 
>> Which database backend are you using for your "dc=vt,dc=edu" database  ?
>> 
>> Regards,
>> Pierre-Arnaud
>> 
>> [1] — http://www.openldap.org/lists/openldap-software/200402/msg00508.html
>> 
>> 
>> On 28 juin 2011, at 18:58, Daniel Fisher wrote:
>> 
>>> Can anyone provide some sample code for using the paged results control?
>>> This is basically what I'm doing now:
>>> 
>>>   PagedResultsImpl prc = new PagedResultsImpl();
>>>   prc.setCritical(true);
>>>   prc.setSize(5);
>>> 
>>>   SearchRequest request = new SearchRequestImpl();
>>>   request.setScope(SearchScope.SUBTREE);
>>>   request.setBase(new Dn("dc=vt,dc=edu"));
>>>   request.setFilter("(uid=*)");
>>>   request.addAllControls(new Control[] {prc, });
>>> 
>>> OpenLDAP is reporting:
>>> 
>>> conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged results
>>> control value is absent
>>> 
>>> Thanks.
>>> 
>>> --Daniel Fisher
>> 
>> 


Re: Paged Results Control

Posted by Daniel Fisher <df...@vt.edu>.
I'm testing OpenLDAP 2.4.23 with bdb. Paged results work fine with JNDI and
JLDAP, so I'm confident the server is configured correctly. I glanced at the
studio code, but I didn't see anything that wasn't using or delegating to a
JNDI PagedResultsControl. Can you point me to some source that uses
org.apache.directory.shared.ldap.model.message.controls.PagedResultsImpl
? Thanks.

--Daniel Fisher

On Wed, Jun 29, 2011 at 3:02 AM, Pierre-Arnaud Marcelot <pa...@marcelot.net>wrote:

> Hi Daniel,
>
> Studio's current trunk embeds the LDAP API as a replacement for JNDI (you
> can select the one you want on a connection basis).
> I've tested a Paged Search using it on an OpenLDAP 2.4.24 server and it
> worked fine.
> It showed me the required number of results and I was able to move through
> pages.
>
> Although, it didn't work on all database backends, like the "cn=config"
> database for instance.
> It appears only "bdb" and "hdb" database backends support this control. [1]
>
> Which database backend are you using for your "dc=vt,dc=edu" database  ?
>
> Regards,
> Pierre-Arnaud
>
> [1] — http://www.openldap.org/lists/openldap-software/200402/msg00508.html
>
>
> On 28 juin 2011, at 18:58, Daniel Fisher wrote:
>
> > Can anyone provide some sample code for using the paged results control?
> > This is basically what I'm doing now:
> >
> >    PagedResultsImpl prc = new PagedResultsImpl();
> >    prc.setCritical(true);
> >    prc.setSize(5);
> >
> >    SearchRequest request = new SearchRequestImpl();
> >    request.setScope(SearchScope.SUBTREE);
> >    request.setBase(new Dn("dc=vt,dc=edu"));
> >    request.setFilter("(uid=*)");
> >    request.addAllControls(new Control[] {prc, });
> >
> > OpenLDAP is reporting:
> >
> > conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged results
> > control value is absent
> >
> > Thanks.
> >
> > --Daniel Fisher
>
>

Re: Paged Results Control

Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
Hi Daniel,

Studio's current trunk embeds the LDAP API as a replacement for JNDI (you can select the one you want on a connection basis).
I've tested a Paged Search using it on an OpenLDAP 2.4.24 server and it worked fine.
It showed me the required number of results and I was able to move through pages.

Although, it didn't work on all database backends, like the "cn=config" database for instance.
It appears only "bdb" and "hdb" database backends support this control. [1]

Which database backend are you using for your "dc=vt,dc=edu" database  ?

Regards,
Pierre-Arnaud

[1] — http://www.openldap.org/lists/openldap-software/200402/msg00508.html


On 28 juin 2011, at 18:58, Daniel Fisher wrote:

> Can anyone provide some sample code for using the paged results control?
> This is basically what I'm doing now:
> 
>    PagedResultsImpl prc = new PagedResultsImpl();
>    prc.setCritical(true);
>    prc.setSize(5);
> 
>    SearchRequest request = new SearchRequestImpl();
>    request.setScope(SearchScope.SUBTREE);
>    request.setBase(new Dn("dc=vt,dc=edu"));
>    request.setFilter("(uid=*)");
>    request.addAllControls(new Control[] {prc, });
> 
> OpenLDAP is reporting:
> 
> conn=1014 op=1 SEARCH RESULT tag=101 err=2 nentries=0 text=paged results
> control value is absent
> 
> Thanks.
> 
> --Daniel Fisher