##// END OF EJS Templates
Refactor: extract AuthSourceLdap#search_attributes...
Eric Davis -
r3339:d828122009cd
parent child
Show More
@@ -41,8 +41,7 class AuthSourceLdap < AuthSource
41 dn = String.new
41 dn = String.new
42 ldap_con.search( :base => self.base_dn,
42 ldap_con.search( :base => self.base_dn,
43 :filter => object_filter & login_filter,
43 :filter => object_filter & login_filter,
44 # only ask for the DN if on-the-fly registration is disabled
44 :attributes=> search_attributes) do |entry|
45 :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry|
46 dn = entry.dn
45 dn = entry.dn
47 attrs = get_user_attributes_from_ldap_entry(entry) if onthefly_register?
46 attrs = get_user_attributes_from_ldap_entry(entry) if onthefly_register?
48 logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
47 logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
@@ -95,6 +94,16 class AuthSourceLdap < AuthSource
95 ]
94 ]
96 end
95 end
97
96
97 # Return the attributes needed for the LDAP search. It will only
98 # include the user attributes if on-the-fly registration is enabled
99 def search_attributes
100 if onthefly_register?
101 ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail]
102 else
103 ['dn']
104 end
105 end
106
98 # Check if a DN (user record) authenticates with the password
107 # Check if a DN (user record) authenticates with the password
99 def authenticate_dn(dn, password)
108 def authenticate_dn(dn, password)
100 if dn.present? && password.present?
109 if dn.present? && password.present?
General Comments 0
You need to be logged in to leave comments. Login now