From 3e3d7c8d4f4f93fae3c81eb20a13af8fbe3600ef Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 19 Feb 2012 18:13:46 +0000 Subject: Friendly response when the LDAP connection fails. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8911 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/auth_source.rb | 4 ++++ app/models/auth_source_ldap.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'app/models') diff --git a/app/models/auth_source.rb b/app/models/auth_source.rb index ae50febc5..933be904a 100644 --- a/app/models/auth_source.rb +++ b/app/models/auth_source.rb @@ -15,6 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Generic exception for when the AuthSource can not be reached +# (eg. can not connect to the LDAP) +class AuthSourceException < Exception; end + class AuthSource < ActiveRecord::Base include Redmine::Ciphering diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index cfb02b881..5c6d28cb2 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -40,8 +40,8 @@ class AuthSourceLdap < AuthSource logger.debug "Authentication successful for '#{login}'" if logger && logger.debug? return attrs.except(:dn) end - rescue Net::LDAP::LdapError => text - raise "LdapError: " + text + rescue Net::LDAP::LdapError => e + raise AuthSourceException.new(e.message) end # test the connection to the LDAP -- cgit v1.2.3