From: brabuhr@... Date: 2010-05-25T03:40:17+09:00 Subject: Re: Active Directory in Ruby on rails On Mon, May 24, 2010 at 6:27 AM, Periyasamy Ramachandiran wrote: > What is Active Directory authentication?. How to use in Ruby on rails?. Using Apache SSPI: http://www.zorched.net/2007/06/04/active-directory-authentication-for-ruby-on-rails/ Using LDAP: http://www.ruby-forum.com/topic/55450#37973 A slightly different version using LDAP: require 'net/ldap' class User def self.authenticate(username, password) return false if username.to_s.size == 0 return false if password.to_s.size == 0 begin ldap = Net::LDAP.new( :host => AD_DOMAIN_CONTROLLER, :port => 389, :auth => { :method => :simple, :username => "#{username}", # <- AD UPN :password => "#{password}" } ) rescue return false end ldap.bind ? User.find_by_login("#{username}") : nil end end