summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-02-17 16:35:35 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-02-17 16:35:35 +0000
commit4f268c5606415bbfe83bcc6e443e98ddaf7747d4 (patch)
tree538dc68c0c3104991dcea2b9a5137822cdb567da
parent9e22faa640c0d1707da4c2203a6e3f936683b4c9 (diff)
downloadredmine-4f268c5606415bbfe83bcc6e443e98ddaf7747d4.tar.gz
redmine-4f268c5606415bbfe83bcc6e443e98ddaf7747d4.zip
Refactor: extract an #authenticate_dn method in AuthSourceLdap
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3441 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/auth_source_ldap.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index 04f4c89b3..d3ede3005 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -49,12 +49,13 @@ class AuthSourceLdap < AuthSource
end
return nil if dn.empty?
logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug?
- # authenticate user
- ldap_con = initialize_ldap_con(dn, password)
- return nil unless ldap_con.bind
- # return user's attributes
- logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
- attrs
+
+ if authenticate_dn(dn, password)
+ logger.debug "Authentication successful for '#{login}'" if logger && logger.debug?
+ return attrs
+ else
+ return nil
+ end
rescue Net::LDAP::LdapError => text
raise "LdapError: " + text
end
@@ -96,6 +97,12 @@ class AuthSourceLdap < AuthSource
:auth_source_id => self.id
]
end
+
+ # Check if a DN (user record) authenticates with the password
+ def authenticate_dn(dn, password)
+ ldap_con = initialize_ldap_con(dn, password)
+ return ldap_con.bind
+ end
def self.get_attr(entry, attr_name)
if !attr_name.blank?