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


28
29
30
# File 'app/models/auth_source_ldap.rb', line 28

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

#auth_method_nameObject


52
53
54
# File 'app/models/auth_source_ldap.rb', line 52

def auth_method_name
  "LDAP"
end

#authenticate(login, password) ⇒ Object


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

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


45
46
47
48
49
50
# File 'app/models/auth_source_ldap.rb', line 45

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