diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-19 16:33:01 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-02-19 16:33:01 +0000 |
commit | d828122009cdaaf5f84dd178798e4901f07c326e (patch) | |
tree | 1cdc033b1c9f640542ee27bcd2ec95a5729c86f1 /app/models | |
parent | 026fbb99a6380054545c14c16590e96a9e77995c (diff) | |
download | redmine-d828122009cdaaf5f84dd178798e4901f07c326e.tar.gz redmine-d828122009cdaaf5f84dd178798e4901f07c326e.zip |
Refactor: extract AuthSourceLdap#search_attributes
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3453 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/auth_source_ldap.rb | 13 |
1 files changed, 11 insertions, 2 deletions
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? |