summaryrefslogtreecommitdiffstats
path: root/app/models/auth_source_ldap.rb
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-02-16 17:03:54 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-02-16 17:03:54 +0000
commitb3330d399543878c2e49df16ed4b73add9afd560 (patch)
tree50d72755880b63adc2aeada7a7f1709710be62ff /app/models/auth_source_ldap.rb
parent7b6b147761a689aa07d83068e77348a3d3f84cfa (diff)
downloadredmine-b3330d399543878c2e49df16ed4b73add9afd560.tar.gz
redmine-b3330d399543878c2e49df16ed4b73add9afd560.zip
Refactor: Extract method from AuthSourceLdap#authenticate
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3439 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/auth_source_ldap.rb')
-rw-r--r--app/models/auth_source_ldap.rb15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index a619b2f85..04f4c89b3 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -44,10 +44,8 @@ class AuthSourceLdap < AuthSource
# 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|
dn = entry.dn
- attrs = [:firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname),
- :lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname),
- :mail => AuthSourceLdap.get_attr(entry, self.attr_mail),
- :auth_source_id => self.id ] if onthefly_register?
+ attrs = get_user_attributes_from_ldap_entry(entry) if onthefly_register?
+
end
return nil if dn.empty?
logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
@@ -89,6 +87,15 @@ class AuthSourceLdap < AuthSource
options.merge!(:auth => { :method => :simple, :username => ldap_user, :password => ldap_password }) unless ldap_user.blank? && ldap_password.blank?
Net::LDAP.new options
end
+
+ def get_user_attributes_from_ldap_entry(entry)
+ [
+ :firstname => AuthSourceLdap.get_attr(entry, self.attr_firstname),
+ :lastname => AuthSourceLdap.get_attr(entry, self.attr_lastname),
+ :mail => AuthSourceLdap.get_attr(entry, self.attr_mail),
+ :auth_source_id => self.id
+ ]
+ end
def self.get_attr(entry, attr_name)
if !attr_name.blank?