# Re: ruby-ldap and paged results on windows

**URL:** <https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725>\
**Category:** Ruby\
**Created:** [August 22, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725 "2007-08-22T16:59:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 22, 2007, 4:59pm UTC](https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725/1 "2007-08-22T16:59:36Z")

</div>

On 8/21/07, Dave K. \<dave / [davewking.com](http://davewking.com)\> wrote:

> > Hi-  
> > I’m trying to get paged results to work with ruby-ldap against  
> > Active Directory in Windows. I compiled ruby-ldap 0.9.7 following the  
> > directions on  
> > [http://www.turnofthecrank.com/2006/09/11/ruby-ldap-and-win32/](http://www.turnofthecrank.com/2006/09/11/ruby-ldap-and-win32/)
> > 
> > Then I tried to run this code I found. The error I get is that ruby  
> > can’t find the constant LDAP\_CONTROL\_PAGEDRESULTS and if I put  
> > LDAP.constants it’s not listed. Any ideas?

> The literal value of the control is “1.2.840.113556.1.4.319”  
> You might try defining that in your code and see if it works. (If you have  
> sharp eyes you’ll notice that the enterprise number in the OID belongs to  
> Microsoft. Paged controls started life as a hack to make Active Directory  
> performance slightly less horrible.)

> If you’re still having trouble, try the Net::LDAP library. It supports  
> paged  
> results transparently.

Thanks for the tip. I tried setting the value of the control, then I  
got  
an error that said  
uninitialized constant LDAP\_OPT\_SERVER\_CONTROLS (NameError)  
Somewhere I found that this should be 0x12 (which may be wrong) so I set  
it to that and got this error  
`set\_option’: the set\_option() function is unimplemented on this machine  
(NotImplementedError)

So it looks like my problems may be bigger than undefined constants.  
I’ve  
also been looking at Net::LDAP as well, the only problem I’ve found  
there  
is that it doesn’t parse my ldap filters right so I have to rewrite them  
in the Net::LDAP way. For example this filter works fine in ruby-ldap  
(&(samaccounttype=805306368)(|(lastLogonTimestamp\<=128231111837280000)(&(!(lastLogonTimestamp=\*)(whenCreated\<=20070522000000.0Z)))))

but in Net::LDAP it gives me this error

c:/ruby/lib/ruby/gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap/filter.rb:302:in  
`initialize’: invalid filter syntax (Net::LDAP::LdapError)

when i run it like this

filter =  
Net::LDAP::Filter.construct(“(&(samaccounttype=805306368)(|(lastLogonTimestamp\<=128231111837280000)(&(!(lastLogonTimestamp=\*)(whenCreated\<=20070522000000.0Z)))))”)

I can rewrite my stuff to use the Net::LDAP filters, but it would be  
nice  
to just use the ldap filter string.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 22, 2007, 5:55pm UTC](https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725/2 "2007-08-22T17:55:46Z")

</div>

On 8/22/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> (“(&(samaccounttype=805306368)(|(lastLogonTimestamp\<=128231111837280000)(&(!(lastLogonTimestamp=\*)(whenCreated\<=  
> 20070522000000.0Z)))))”)
> 
> I can rewrite my stuff to use the Net::LDAP filters, but it would be nice  
> to just use the ldap filter string.

I can help you debug this. The only thing I can see offhand that is  
weird is  
the Zulu timestring. You can help me by taking each of the individual  
branches in your filter, without the &s and the !, and just run them one  
by  
one through Net::LDAP::Filter.construct till you find the one that  
breaks.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 26, 2007, 7:35am UTC](https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725/3 "2007-08-26T07:35:58Z")

</div>

What I really wanted to do was this

(&(samaccounttype=805306368)(|(lastLogonTimestamp\<=128231111837280000)(&(!(lastLogonTimestamp=\*))(whenCreated\<=  
20070522000000.0Z))))

and that works.

Thanks

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [August 26, 2007, 11:39am UTC](https://www.ruby-forum.com/t/re-ruby-ldap-and-paged-results-on-windows/112725/4 "2007-08-26T11:39:14Z")

</div>

On 8/26/07, Dave K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> What I really wanted to do was this
> 
> (&(samaccounttype=805306368)(|(lastLogonTimestamp\<=128231111837280000)(&(!(lastLogonTimestamp=\*))(whenCreated\<=  
> 20070522000000.0Z))))
> 
> and that works.
> 
> Thanks

Actually, you had a syntax error in the first version. The ! operator is  
only allowed to take one branch.
