# LDAP searches don't stop

**URL:** <https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327>\
**Category:** Ruby\
**Created:** [August 17, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327 "2006-08-17T16:11:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 17, 2006, 4:11pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/1 "2006-08-17T16:11:22Z")

</div>

Hello,

I’m trying to figure out how to search an LDAP server. I can connect and  
I  
see searches pass by if I sniff on the network interface. But the search  
command never stops, even tough I limit it to 1 second. (Can I limit the  
search to 1 result?)

irb(main):001:0\> require ‘ldap’  
=\> true  
irb(main):002:0\> conn = LDAP::Conn.new(“someldapserver”, 389)  
=\> #LDAP::Conn:0xb7afb900  
irb(main):003:0\> conn.set\_option(LDAP::LDAP\_OPT\_PROTOCOL\_VERSION, 3)  
=\> #LDAP::Conn:0xb7afb900  
irb(main):004:0\> conn.bind(“ldapusername”, “ldappassword”)  
=\> #LDAP::Conn:0xb7afb900  
irb(main):005:0\> conn.search2(“dc=somedc”,  
LDAP::LDAP\_SCOPE\_SUBTREE, “somefilter”, nil,false, 1)

This keeps running forever instead of for 1 second…  
Any ideas on how to solve that? I see a right result coming over the  
network  
interface so the program can stop!

Regards,  
Bart

---

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 17, 2006, 4:23pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/2 "2006-08-17T16:23:25Z")

</div>

On 8/17/06, Bart B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> =\> #LDAP::Conn:0xb7afb900
> 
> Regards,  
> Bart

What happens if you use ldapsearch against this server? What happens  
if you use Net::LDAP?

---

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 17, 2006, 4:47pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/3 "2006-08-17T16:47:29Z")

</div>

Francis C. wrote:

> What happens if you use ldapsearch against this server?

ldapsearch works fine and fast.

Bart

---

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 17, 2006, 5:20pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/4 "2006-08-17T17:20:35Z")

</div>

Bart B. wrote:

> =\> #LDAP::Conn:0xb7afb900

Right the error is in the details. I used DC in the query instead of dc.  
The  
server responded with some other servers to choose from, some of which  
did  
not exist. So the program took forever trying to query those servers…  
(I don’t know whether it’s useful if I report this situation to the LDAP  
module author?)

Thanks for your help!  
Bart

---

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 17, 2006, 5:02pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/5 "2006-08-17T17:02:32Z")

</div>

Bart B. wrote:

> =\> #LDAP::Conn:0xb7afb900

After some time the system stops:  
ruby myprogram.rb  
myprogram:8:in `search’: Operations error (LDAP::ResultError)  
from myprogram.rb:8  
But that error is nowhere explained. Is there something wrong with my  
connection? The server is an Active Directory server, can that make a  
difference?

Bart

---

<div class="post-metadata">

**Author:** ![bartb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/848f3c/32.png) [@bartb](https://www.ruby-forum.com/u/bartb)\
**Post date:** [August 18, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap-searches-dont-stop/65327/6 "2006-08-18T14:17:17Z")

</div>

Bart B. wrote:

> Right the error is in the details. I used DC in the query instead of dc.  
> The server responded with some other servers to choose from, some of which  
> did not exist. So the program took forever trying to query those  
> servers…

Yesterday I tried Net::LDAP and it worked even with a capital DC in the  
search base. Net::LDAP seems to have a cleaner interface so perhaps I’ll  
switch the system over, performance does not seem to be an issue either.

Bart
