Active Directory in Ruby on rails

Hi All,

What is Active Directory authentication?. How to use in Ruby on rails?.

Regards,

Periyasamy.R

On Mon, May 24, 2010 at 6:27 AM, Periyasamy R.
[email protected] wrote:

What is Active Directory authentication?. How to use in Ruby on rails?.

Using Apache SSPI:

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

unknown wrote:

On Mon, May 24, 2010 at 6:27 AM, Periyasamy R.
[email protected] wrote:

What is Active Directory authentication?. How to use in Ruby on rails?.

Using Apache SSPI:
Zorched / One-Line Fix | Active Directory Authentication for Ruby on Rails

Using LDAP:
Rails and Windows Active Directory Authentication? - Rails - Ruby-Forum

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

Hi,

Great!. It worked for me.

Thanks,
Periyasamy.R