ldap

Ruby’s net_ldap library works great for this.

IIRC, you can do a gem install ruby_net_ldap. Google for something like “rails ldap authenticate” and you should be able to find examples of using it. Basically, you can just call it’s bind method and if that is successful, you know that you have authenticated.

A bit late, but for those who might search the archives, I like acts_as_ldap_authenticated (for my rails 1.2.6 site) http://www.noitulove.ch/ldap-authentication-plugin-for-rails/ As the post indicates, it is largely a drop in replacement for the acts_as_authenticated plugin.

But if you also use Oracle, there is a library conflict. See this for the work around (require ‘ldap’ before the rails boot line in environment.rb) http://lists.rubyonrails.org/pipermail/rails/2006-April/032583.html

from this page, http://wiki.rubyonrails.org/rails/pages/ldap

i see that there are at least three different ways for rails to implement ldap:

* Net-LDAP - Pure Ruby LDAP API * Ruby/LDAP - Interface to some common LDAP libraries * ActiveLDAP - the ActiveRecord way

-what are some advantages of each over the others? disadvantages? -comparative ease of use in setting up and maintenance? finding resources on the net and books? -what factors contributed in your choice of which implementation to go with?

it seems from some postings in this group that folks seem to recommend either net_ldap and/or activeldap for ldap authentication with rails. why?

thank you.

I've just used Net-LDAP, but not before wasting lots of time trying to get ActiveLDAP working. For me, a relatively new RoR user, I never found a single place with complete documentation on how to set it up in a Rails app. The docs for Net-LDAP had the best examples for me, as I'm only after simple auth. I don't need a full OO API to build a dir management system which ActiveLDAP promises.

<http://rubyfurnace.com/docs/ruby-net-ldap-0.0.4/&gt; <http://wiki.rubyonrails.org/rails/pages/HowtoAuthenticateWithRubyNetLdap&gt; <http://www.rich-waters.com/blog/2007/02/using-domino-logins-ldap-for-a-ruby-on-rails-app.html&gt;

Hal Fulton's (great) book The Ruby Way has a page on interfacing to LDAP - I took his advice and investigated all of them to form my own opinion. Hal also mentions acts_as_authenticated in The Rails Way (also great) which gave me clues for where the code goes in my app.

George

from this page, http://wiki.rubyonrails.org/rails/pages/ldap

i see that there are at least three different ways for rails to implement ldap:

* Net-LDAP - Pure Ruby LDAP API * Ruby/LDAP - Interface to some common LDAP libraries * ActiveLDAP - the ActiveRecord way

-what are some advantages of each over the others? disadvantages? -comparative ease of use in setting up and maintenance? finding resources on the net and books? -what factors contributed in your choice of which implementation to go with?

it seems from some postings in this group that folks seem to recommend either net_ldap and/or activeldap for ldap authentication with rails. why?

Oops, of course The Rails Way is by Obie Fernandez. A great reference.

i see that there are at least three different ways for rails to implement ldap:

* Net-LDAP - Pure Ruby LDAP API * Ruby/LDAP - Interface to some common LDAP libraries * ActiveLDAP - the ActiveRecord way

-what are some advantages of each over the others? disadvantages?

ActiveLDAP is higher level - it depends on Ruby/LDAP for the low level LDAP interactions and then builds a ruby object corresponding to your LDAP object. If you want to display your LDAP information on your Rails-based web site, it is the way to go. If you are just going to use LDAP for authenticating users, it is overkill.

As I mentioned previously, if your site is Rails 1.x, acts_as_ldap_authenticated was a drop in replacement for acts_as_authenticated. I don't know how much fiddling it will take to get that plugin to work in Rails 2.0, but I will probably find out in the next 2-3 months when I convert some sites.