Active Directory in Ruby on rails

Hi All,

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

Regards,

Periyasamy.R

···

--
Posted via http://www.ruby-forum.com/.

Using Apache SSPI:

Using LDAP:

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

···

On Mon, May 24, 2010 at 6:27 AM, Periyasamy Ramachandiran <periyasamy@riverstonetech.com> wrote:

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

unknown wrote:

···

On Mon, May 24, 2010 at 6:27 AM, Periyasamy Ramachandiran > <periyasamy@riverstonetech.com> 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
--
Posted via http://www.ruby-forum.com/\.