# Ruby-net-ldap search result pagination

**URL:** <https://www.ruby-forum.com/t/ruby-net-ldap-search-result-pagination/173913>\
**Category:** Ruby\
**Created:** [August 18, 2009, 8:10am UTC](https://www.ruby-forum.com/t/ruby-net-ldap-search-result-pagination/173913 "2009-08-18T08:10:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paragados](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@paragados](https://www.ruby-forum.com/u/paragados)\
**Post date:** [August 18, 2009, 8:10am UTC](https://www.ruby-forum.com/t/ruby-net-ldap-search-result-pagination/173913/1 "2009-08-18T08:10:49Z")

</div>

Hi,

I’m new to ldap and I need to paginate the search result that it will  
return.  
Is there a control that needs to be set like in offset in DB?  
Or does will paginate work with ruby-net-ldap?

Thanks.

---

<div class="post-metadata">

**Author:** ![paragados](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@paragados](https://www.ruby-forum.com/u/paragados)\
**Post date:** [August 18, 2009, 6:19pm UTC](https://www.ruby-forum.com/t/ruby-net-ldap-search-result-pagination/173913/2 "2009-08-18T18:19:59Z")

</div>

I think ruby-net-ldap automatically already uses the paged search  
control  
internally but uses this to populate the result returned. LDAP doesn’t  
have  
an offset for the paged result but instead returns a cookie, see  
[RFC 2696 - LDAP Control Extension for Simple Paged Results Manip (RFC2696)](http://www.faqs.org/rfcs/rfc2696.html).

What ruby-net-ldap doesn’t have that I wish it did was an implementation  
of  
the server side sort control or the VLC control

[http://blogs.sun.com/kanthi/entry/ldap\_paged\_results\_more](http://blogs.sun.com/kanthi/entry/ldap_paged_results_more).

On Tue, Aug 18, 2009 at 12:10 AM, Mx MQP  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![paragados](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@paragados](https://www.ruby-forum.com/u/paragados)\
**Post date:** [August 26, 2009, 8:28am UTC](https://www.ruby-forum.com/t/ruby-net-ldap-search-result-pagination/173913/3 "2009-08-26T08:28:21Z")

</div>

Dominic S. wrote:

> I think ruby-net-ldap automatically already uses the paged search  
> control  
> internally but uses this to populate the result returned. LDAP doesn’t  
> have  
> an offset for the paged result but instead returns a cookie, see  
> [RFC 2696 - LDAP Control Extension for Simple Paged Results Manip (RFC2696)](http://www.faqs.org/rfcs/rfc2696.html).
> 
> What ruby-net-ldap doesn’t have that I wish it did was an implementation  
> of  
> the server side sort control or the VLC control
> 
> [http://blogs.sun.com/kanthi/entry/ldap\_paged\_results\_more](http://blogs.sun.com/kanthi/entry/ldap_paged_results_more).
> 
> On Tue, Aug 18, 2009 at 12:10 AM, Mx MQP

Hello Dominic,

Thank you for your reply.  
But I am sorry I don’t understand how to set the control.  
I already have my search code, but I don’t understand how should I  
incorporate the paged result returned by the server.  
Code as follows:

result = ldap.search( :base =\> treebase, :filter =\> filter) do |entry|

```
  debug "DN:#{entry.dn.inspect}"

```

end

Can you please give me more idea on where should I set the  
“simplePageSize”  
like in the sample below.

$ ./dsconfig -h localhost -p 1389 -D “cn=Directory Manager” -w password  
set-access-control-  
handler-prop   
–add global-aci:“(targetcontrol="1.2.840.113556.1.4.319")(version  
3.0; acl "Allow Simple Paged  
Results Access"; allow(read) userdn =  
"ldap:///uid=admin,ou=people,dc=example,dc=com";)” -n

Thanks.
