# Ruby-net-ldap paged search control

**URL:** <https://www.ruby-forum.com/t/ruby-net-ldap-paged-search-control/174467>\
**Category:** Ruby\
**Created:** [August 27, 2009, 4:05am UTC](https://www.ruby-forum.com/t/ruby-net-ldap-paged-search-control/174467 "2009-08-27T04:05:07Z")\
**Posts on this page:** 1\
**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 27, 2009, 4:05am UTC](https://www.ruby-forum.com/t/ruby-net-ldap-paged-search-control/174467/1 "2009-08-27T04:05:07Z")

</div>

Hi,

Could anyone help me on how to use the ruby-net-ldap paged search  
control?  
I have read in forums that Net::LDAP library supports paged results  
transparently.  
My problem is I don’t know how to embed it in my code.

I need to search users from ldap and paginate the results return by the  
server.

Here is the sample code.

ldap = Net::LDAP.new( {:host =\> LDAP\_SERVER\_IP\_ADDRESS,  
:port =\> LDAP\_SERVER\_PORT } )  
#call LDAP authentication  
ldap.auth( “#{LDAP\_USERNAME}”,"#{LDAP\_PWD}" )

user\_array = []  
user\_hash = {}  
treebase = “sample treebase”  
filter = “myfilter”  
attrs = [“sample attributes”]

#bind LDAP authentication  
if ldap.bind

ldap.search(:base=\>treebase, :filter=\>filter,:attributes=\>attrs) do  
|entry|  
#I process the entry here to store in hash  
user\_hash = {  
:name =\> entry[:cn],  
:lastname=\>entry[:sn]  
}  
end  
user\_array \<\< user\_hash  
end

return user\_array

Please help me on where should do it. Can you please give me code  
snippet so that I can embed it in my code.

Many Thanks.
