From d828122009cdaaf5f84dd178798e4901f07c326e Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Fri, 19 Feb 2010 16:33:01 +0000 Subject: Refactor: extract AuthSourceLdap#search_attributes git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3453 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/auth_source_ldap.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index 4f73621d6..43a0fc8bc 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -41,8 +41,7 @@ class AuthSourceLdap < AuthSource dn = String.new ldap_con.search( :base => self.base_dn, :filter => object_filter & login_filter, - # only ask for the DN if on-the-fly registration is disabled - :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) do |entry| + :attributes=> search_attributes) do |entry| dn = entry.dn attrs = get_user_attributes_from_ldap_entry(entry) if onthefly_register? logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? @@ -95,6 +94,16 @@ class AuthSourceLdap < AuthSource ] end + # Return the attributes needed for the LDAP search. It will only + # include the user attributes if on-the-fly registration is enabled + def search_attributes + if onthefly_register? + ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] + else + ['dn'] + end + end + # Check if a DN (user record) authenticates with the password def authenticate_dn(dn, password) if dn.present? && password.present? -- cgit v1.2.3