Sha256: 4593e565f008edf98270eac43d845c0c1d3f4a8a8e05a03797db2f7b317b9d23

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

module Adauth
    
    # Create a connection to LDAP using Net::LDAP
    #
    # Called as:
    #    Adauth::Connection.bind(username, password)
    #
    # 
    class Connection
        
        # Create a connection to LDAP using Net::LDAP
        #
        # Called as:
        #    Adauth::Connection.bind(username, password)
        #
        #
        def self.bind(login, pass)
            conn = Net::LDAP.new    :host => Adauth.config.server,
                                    :port => Adauth.config.port,
                                    :base => Adauth.config.base,
                                    :auth => { :username => "#{login}@#{Adauth.config.domain}",
                                        :password => pass,
                                        :method => :simple }
            begin
                Timeout::timeout(10){
                    if conn.bind
                        return conn
                    else
                        return nil
                    end
                }
            rescue Timeout::Error
                raise "Unable to connect to LDAP Server"
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
adauth-1.2.1 lib/adauth/connection.rb