Class: AuthSourceLdap

Inherits:
AuthSource show all
Defined in:
app/models/auth_source_ldap.rb

Instance Method Summary

Methods inherited from AuthSource

authenticate

Methods inherited from ActiveRecord::Base

quoted_table_name

Instance Method Details

- (Object) after_initialize



30
31
32
# File 'app/models/auth_source_ldap.rb', line 30

def after_initialize
  self.port = 389 if self.port == 0
end

- (Object) auth_method_name



54
55
56
# File 'app/models/auth_source_ldap.rb', line 54

def auth_method_name
  "LDAP"
end

- (Object) authenticate(login, password)



34
35
36
37
38
39
40
41
42
43
44
# File 'app/models/auth_source_ldap.rb', line 34

def authenticate(, password)
  return nil if .blank? || password.blank?
  attrs = get_user_dn()
  
  if attrs && attrs[:dn] && authenticate_dn(attrs[:dn], password)
    logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
    return attrs.except(:dn)
  end
rescue  Net::LDAP::LdapError => text
  raise "LdapError: " + text
end

- (Object) test_connection

test the connection to the LDAP



47
48
49
50
51
52
# File 'app/models/auth_source_ldap.rb', line 47

def test_connection
  ldap_con = initialize_ldap_con(self., self.)
  ldap_con.open { }
rescue  Net::LDAP::LdapError => text
  raise "LdapError: " + text
end