From fc39d443844bd97073903f45cf0ea93e3f307d52 Mon Sep 17 00:00:00 2001 From: Michael J Rubinsky Date: Sun, 24 Oct 2021 22:13:01 -0400 Subject: [PATCH] Bug: 15077 Support specific case when auth server is unavailable. --- lib/Horde/Core/ActiveSync/Driver.php | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/Horde/Core/ActiveSync/Driver.php b/lib/Horde/Core/ActiveSync/Driver.php index bf7fb7d92..66191abb3 100644 --- a/lib/Horde/Core/ActiveSync/Driver.php +++ b/lib/Horde/Core/ActiveSync/Driver.php @@ -217,10 +217,31 @@ public function authenticate($username, $password, $domain = null) } // Now check Basic. Happens for authtype == 'basic' || 'basic_cert' - if ($conf['activesync']['auth']['type'] != 'cert' && - !$this->_auth->authenticate($username, array('password' => $password))) { - $injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed from ActiveSync client for user %s.', $username)); - return false; + if ($conf['activesync']['auth']['type'] != 'cert') { + try { + $authResult = $this->_auth->authenticate($username, array('password' => $password)); + } catch (Horde_Auth_Exception $e) { + if ($e->getCode() == Horde_Auth::REASON_MESSAGE) { + // This error code would only happen if it's an error + // from the underlaying auth backend, and NOT an invalid + // authentication attempt. + $this->_logger->warn('Authentication server unavailable.'); + + // TODO: Remove BC shim + if (defined('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE')) { + return constant('Horde_ActiveSync::AUTH_REASON_UNAVAILABLE'); + } + + return false; + } + } + + if (!$authResult) { + $injector->getInstance('Horde_Log_Logger')->notice(sprintf('Login failed from ActiveSync client for user %s.', $username)); + return false; + } + + return true; } // Get the username from the registry so we capture it after any