@@ -49,12 +49,13 class AuthSourceLdap < AuthSource | |||||
49 | end |
|
49 | end | |
50 | return nil if dn.empty? |
|
50 | return nil if dn.empty? | |
51 | logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? |
|
51 | logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? | |
52 | # authenticate user |
|
52 | ||
53 |
|
|
53 | if authenticate_dn(dn, password) | |
54 | return nil unless ldap_con.bind |
|
54 | logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? | |
55 |
|
|
55 | return attrs | |
56 | logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? |
|
56 | else | |
57 | attrs |
|
57 | return nil | |
|
58 | end | |||
58 | rescue Net::LDAP::LdapError => text |
|
59 | rescue Net::LDAP::LdapError => text | |
59 | raise "LdapError: " + text |
|
60 | raise "LdapError: " + text | |
60 | end |
|
61 | end | |
@@ -96,6 +97,12 class AuthSourceLdap < AuthSource | |||||
96 | :auth_source_id => self.id |
|
97 | :auth_source_id => self.id | |
97 | ] |
|
98 | ] | |
98 | end |
|
99 | end | |
|
100 | ||||
|
101 | # Check if a DN (user record) authenticates with the password | |||
|
102 | def authenticate_dn(dn, password) | |||
|
103 | ldap_con = initialize_ldap_con(dn, password) | |||
|
104 | return ldap_con.bind | |||
|
105 | end | |||
99 |
|
106 | |||
100 | def self.get_attr(entry, attr_name) |
|
107 | def self.get_attr(entry, attr_name) | |
101 | if !attr_name.blank? |
|
108 | if !attr_name.blank? |
General Comments 0
You need to be logged in to leave comments.
Login now