Class: AuthSourceLdap
- Inherits:
-
AuthSource
- Object
- ActiveRecord::Base
- AuthSource
- AuthSourceLdap
- Defined in:
- app/models/auth_source_ldap.rb
Instance Method Summary
- - (Object) after_initialize
- - (Object) auth_method_name
- - (Object) authenticate(login, password)
-
- (Object) test_connection
test the connection to the LDAP.
Methods inherited from AuthSource
Methods inherited from ActiveRecord::Base
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(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 |
- (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.account, self.account_password) ldap_con.open { } rescue Net::LDAP::LdapError => text raise "LdapError: " + text end |