##// END OF EJS Templates
Refactor: extract an #authenticate_dn method in AuthSourceLdap...
Eric Davis -
r3327:4f268c560641
parent child
Show More
@@ -49,12 +49,13 class AuthSourceLdap < AuthSource
49 49 end
50 50 return nil if dn.empty?
51 51 logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
52 # authenticate user
53 ldap_con = initialize_ldap_con(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?
57 attrs
52
53 if authenticate_dn(dn, password)
54 logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
55 return attrs
56 else
57 return nil
58 end
58 59 rescue Net::LDAP::LdapError => text
59 60 raise "LdapError: " + text
60 61 end
@@ -96,6 +97,12 class AuthSourceLdap < AuthSource
96 97 :auth_source_id => self.id
97 98 ]
98 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 107 def self.get_attr(entry, attr_name)
101 108 if !attr_name.blank?
General Comments 0
You need to be logged in to leave comments. Login now