Class: AuthSourceLdap
- Inherits:
-
AuthSource
- Object
- ActiveRecord::Base
- AuthSource
- AuthSourceLdap
- Defined in:
- app/models/auth_source_ldap.rb
Instance Method Summary collapse
- #after_initialize ⇒ Object
- #auth_method_name ⇒ Object
- #authenticate(login, password) ⇒ Object
-
#test_connection ⇒ Object
test the connection to the LDAP.
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_initialize ⇒ Object
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_name ⇒ Object
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(login, password) return nil if login.blank? || password.blank? attrs = get_user_dn(login) 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 |
#test_connection ⇒ Object
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.account, self.account_password) ldap_con.open { } rescue Net::LDAP::LdapError => text raise "LdapError: " + text end |