@@ -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 |
|
|||
55 | # return user's attributes |
|
|||
56 | logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? |
|
54 | logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? | |
57 | attrs |
|
55 | return attrs | |
|
56 | else | |||
|
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 | |
@@ -97,6 +98,12 class AuthSourceLdap < AuthSource | |||||
97 | ] |
|
98 | ] | |
98 | end |
|
99 | end | |
99 |
|
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 | |||
|
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? | |
102 | entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name] |
|
109 | entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name] |
General Comments 0
You need to be logged in to leave comments.
Login now