# Ruby LDAP

**URL:** <https://www.ruby-forum.com/t/ruby-ldap/95023>\
**Category:** Rails\
**Created:** [May 19, 2006, 3:12pm UTC](https://www.ruby-forum.com/t/ruby-ldap/95023 "2006-05-19T15:12:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephane\_Fourdrinie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ea924/32.png) [@Stephane\_Fourdrinie](https://www.ruby-forum.com/u/Stephane_Fourdrinie)\
**Post date:** [May 19, 2006, 3:12pm UTC](https://www.ruby-forum.com/t/ruby-ldap/95023/1 "2006-05-19T15:12:17Z")

</div>

Anyone has done work with Ruby-Ldap? and maybe could provide some  
examples? I have to admit that I am rather lost using this.

I am looking to do a Rails interface to manage LDAP servers but I can’t  
seem to find how to do this in Ruby and for example retrieve the  
elements, attributes, and change them.

This is what I have done so far…

* * *

#!/appl/ruby/bin/ruby -w

require ‘ldap’

conn = LDAP::Conn.new( ‘ldapserver’, 389 )  
conn.set\_option( LDAP::LDAP\_OPT\_PROTOCOL\_VERSION, 3 )  
res=conn.bind(‘cn=Manager,dc=domain,dc=com’,‘password’)

printf(“connected %s”,res)  
conn.search(‘ou=people,dc=domain,dc=com’,LDAP::LDAP\_SCOPE\_SUBTREE,‘cn=\*’,[‘cn’])  
do |entry|  
dn=entry.get\_dn  
printf(“dn: %s\n”,dn)  
end

* * *

How could I get then the details of an entry, and modify them?

Any help would be greatly appreciated.  
Stephane

---

<div class="post-metadata">

**Author:** ![Stephane\_Fourdrinie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ea924/32.png) [@Stephane\_Fourdrinie](https://www.ruby-forum.com/u/Stephane_Fourdrinie)\
**Post date:** [May 19, 2006, 3:15pm UTC](https://www.ruby-forum.com/t/ruby-ldap/95023/2 "2006-05-19T15:15:25Z")

</div>

I’ve been using the new Net::Ldap which has pretty good documentation.  
The documentation is included with the source.

[http://rubyforge.org/projects/net-ldap/](http://rubyforge.org/projects/net-ldap/)

---

<div class="post-metadata">

**Author:** ![Stephane\_Fourdrinie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ea924/32.png) [@Stephane\_Fourdrinie](https://www.ruby-forum.com/u/Stephane_Fourdrinie)\
**Post date:** [May 20, 2006, 4:38pm UTC](https://www.ruby-forum.com/t/ruby-ldap/95023/3 "2006-05-20T16:38:06Z")

</div>

Hi,

Have a look at Enterprise Integration with Ruby [http://  
[pragmaticprogrammer.com/titles/fr\_eir/index.html](http://pragmaticprogrammer.com/titles/fr_eir/index.html)]. It dedicates about  
27 pages to the topic, and it discusses some of the libraries that  
have been mentioned in other replies. One of the free excerpts is  
even from the LDAP chapter!

Regards,  
Craig

---

<div class="post-metadata">

**Author:** ![Stephane\_Fourdrinie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ea924/32.png) [@Stephane\_Fourdrinie](https://www.ruby-forum.com/u/Stephane_Fourdrinie)\
**Post date:** [May 19, 2006, 6:45pm UTC](https://www.ruby-forum.com/t/ruby-ldap/95023/4 "2006-05-19T18:45:21Z")

</div>

On 5/19/06, Stephane Fourdrinier - Fusemail [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Anyone has done work with Ruby-Ldap? and maybe could provide some  
> examples? I have to admit that I am rather lost using this.
> 
> I am looking to do a Rails interface to manage LDAP servers but I can’t  
> seem to find how to do this in Ruby and for example retrieve the  
> elements, attributes, and change them.

You might look at ActiveLDAP, an ActiveRecord like layer on top of the  
ruby ldap libs.

[http://rubyforge.org/projects/ruby-activeldap/](http://rubyforge.org/projects/ruby-activeldap/)  
[http://wiki.rubyonrails.com/rails/pages/ActiveLDAP](http://wiki.rubyonrails.com/rails/pages/ActiveLDAP)

cheers,  
jh

–  
James H.  
Web application developer  
Vancouver, BC

“Developing a coherent political analysis is in many respects  
contingent upon an ability to connect one context to another, a  
process not dissimilar to playing the kid’s game of dot-to-dot.”

- Ward Churchill, from ‘“A Government of Laws”?’
