Class: AuthSourceLdap

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

Instance Method Summary collapse

Methods inherited from AuthSource

#account_password, #account_password=, #allow_password_changes?, allow_password_changes?, authenticate

Methods included from Redmine::Ciphering

cipher_key, decrypt_text, encrypt_text, included

Instance Method Details

#after_initializeObject



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

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

#auth_method_nameObject



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

def auth_method_name
  "LDAP"
end

#authenticate(login, password) ⇒ Object



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 '#{}'" if logger && logger.debug?
    return attrs.except(:dn)
  end
rescue  Net::LDAP::LdapError => text
  raise "LdapError: " + text
end

#test_connectionObject

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