# Ldap

**URL:** <https://www.ruby-forum.com/t/ldap/102445>\
**Category:** Ruby\
**Created:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445 "2006-08-15T14:17:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445/1 "2006-08-15T14:17:34Z")

</div>

Are folks just using net/ldap or are there some other ldap libraries  
that folks prefer?

What I’d like is to be able to bind to the server then make multiple  
queries, modifications, etc.

Thanks for any guidance.

Mike B.

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445/2 "2006-08-15T14:17:35Z")

</div>

Personally I use net/ldap and for my needs it does the job. Plus I use  
the Ruby O.-Click Installer for Windows so compiling another LDAP  
library is a bit of a stretch for me.

I haven’t looked at the docs lately. Is this library lacking the  
ability to open an LDAP session and then post multiple calls against it  
later on?

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445/3 "2006-08-15T14:17:35Z")

</div>

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

> Are folks just using net/ldap or are there some other ldap libraries  
> that folks prefer?
> 
> What I’d like is to be able to bind to the server then make multiple  
> queries, modifications, etc.

According to what Francis has told me, it should be possible to do  
that with Net::LDAP, although internally it will connect and  
disconnect as necessary. It is my understanding – which could be  
wrong – that LDAP connections are rarely persistent and require  
rebinding in any case, but Net::LDAP should be hiding this from you.

Net::LDAP is the only _pure_ Ruby LDAP library in existence right now.  
The main other way of connecting to LDAP is with ruby-ldap (or is it  
ldap-ruby?) which uses bindings to a C library and requires compiling  
to use.

-austin

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445/4 "2006-08-15T14:17:36Z")

</div>

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

> 

Get Net::LDAP and read the Rdoc for Net::LDAP#open. As Austin said, this  
library is very disciplined (and documented) about how it uses the  
network  
(unlike the native-C libraries), and it’s pure Ruby- no compiler needed  
on  
any platform.

To your specific point, you can specify connection and authentication  
parameters to Net::LDAP#open, and then pass it a Ruby block. The #open  
call  
will pass a Net::LDAP object to your block, and you can make any number  
of  
LDAP calls on the object. All calls inside the block will take place on  
the  
same network connection to the server, and the authentication (binding)  
will  
be done automatically.

If you have questions or need support, post to this list. Good luck.

---

<div class="post-metadata">

**Author:** ![barjunk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@barjunk](https://www.ruby-forum.com/u/barjunk)\
**Post date:** [August 15, 2006, 2:17pm UTC](https://www.ruby-forum.com/t/ldap/102445/5 "2006-08-15T14:17:35Z")

</div>

Yeah, looking at the basic test cases for the library you can define a  
general LDAP session and then invoke methods against it as you see fit.  
For example,

ldap = Net::LDAP.new :host =\> my\_hostname, :port =\> my\_port, :auth =\>  
my\_auth

Once that ldap object is defined then it can be accessed by various  
methods that come with the net/ldap library. All in all I think LDAP in  
general is rather straightforward, so working with one of these  
libraries shouldn’t force you to reinvent the wheel or anything.
