From 82dd1b2bf29d3e84eddb1a45c14b7ddb9adf7360 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 18 Feb 2010 16:55:05 +0000 Subject: [PATCH] Refactor: Moved the check for an empty DN to authenticate_dn git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3449 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/auth_source_ldap.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index d3ede300..da453ae9 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -45,10 +45,9 @@ class AuthSourceLdap < AuthSource :attributes=> (onthefly_register? ? ['dn', self.attr_firstname, self.attr_lastname, self.attr_mail] : ['dn'])) 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? end - return nil if dn.empty? - logger.debug "DN found for #{login}: #{dn}" if logger && logger.debug? if authenticate_dn(dn, password) logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? @@ -100,6 +99,8 @@ class AuthSourceLdap < AuthSource # Check if a DN (user record) authenticates with the password def authenticate_dn(dn, password) + return nil if dn.empty? + ldap_con = initialize_ldap_con(dn, password) return ldap_con.bind end