Class: Oxford::LDAPAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/oxford/ldap.rb

Instance Method Summary collapse

Constructor Details

#initializeLDAPAdapter

Returns a new instance of LDAPAdapter.



3
4
5
6
# File 'lib/oxford/ldap.rb', line 3

def initialize
  load_config
  setup_connection
end

Instance Method Details

#connected?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'lib/oxford/ldap.rb', line 24

def connected?
  begin
    ActiveLdap::Base.search(:base => @base, :filter => '(cn=admin)', :scope => :sub)
    return true
  rescue => e
    return false
  end
end

#load_configObject



8
9
10
11
# File 'lib/oxford/ldap.rb', line 8

def load_config
  config = YAML.load_file(Oxford::Runner.config)
  config['ldap'].each { |key, value| instance_variable_set "@#{key}", value }
end

#setup_connectionObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/oxford/ldap.rb', line 13

def setup_connection
  ActiveLdap::Base.setup_connection(
    :host     => @host,
    :port     => @port,
    :base     => @base,
    :method   => @method,
    :bind_dn  => @user,
    :password => @pass
  )
end