LDAP in Ruby is better than LDAP in C#/.NET. Looking at it, I can't say it's much different minus the cruft from .NET.
Experiencing it while 
actually writing code, it's 
very different. I can't explain it, except to show it to you and tell you try it. 
Ruby LDAP code is at github
even though 
existing solutions with good examples point you to what are now broken links.
To install (despite README.txt saying otherwise):
gem install ruby-net-ldap
And here's some LDAP login/authorization/auth code:
require 'rubygems'
require 'net/ldap'
ldap = Net::LDAP.new
ldap.host = "ldap.example.com"
ldap.port = "389"
username = "human_interest_stories"
password = "obituary"
ldap.auth "uid=#{username},ou=users,dc=example,dc=com", password
is_authorized = ldap.bind # returns true if auth works, false otherwise (or throws error if it can't connect to the server)
#searching the LDAP from Damana (linked above too)
filter = Net::LDAP::Filter.eq( "uid", username )
#attrs = ["ou" , "objectClass"] # you can specify attributes
attrs = []
ldap.search( :base => "ou=users,dc=example,dc=com", :attributes => attrs, :filter => filter, :return_result => true ) do |entry|
    puts entry.dn
    entry.attribute_names.each do |n|
        puts "#{n} = #{entry[n]}"
    end
end
  
Hope it helps.
	
		
		
		Hey! Why don't you make your life easier and subscribe to the full post
		or short blurb RSS feed?  I'm so confident you'll love my smelly pasta plate 
		wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
		
		
	 
	
		
		
		
			Leave a comment
			
				
				
				
				Great post, I've been looking for a couple of ours for a snippet for connecting to Active Directory from ruby and your post did the trick. :)
				Posted by 
Ahmed El.Hussaini
				on Feb 01, 2010 at 05:02 AM UTC - 6 hrs
				
 	
			
				
				
				
				
				
				This helped me greatly. Thanks for the easy to understand example.
				Posted by Jason
				on Jun 22, 2012 at 09:57 AM UTC - 6 hrs
				
	
			
					
			
			Leave a comment