From a267a251659acf3bb311e3bf6cdc1f1fee8b4b39 Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Mon, 14 May 2012 22:57:52 +1200 Subject: [PATCH] Retry contacting LDAP server and fail with 503 if unavailable. We can't call $request->DoResponse() at this point because we haven't done all that stuff yet... --- inc/drivers_ldap.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index 765b3fda..bb0b2e75 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -294,8 +294,13 @@ function LDAP_check($username, $password ){ $ldapDriver = getStaticLdap(); if ( !$ldapDriver->valid ) { - dbg_error_log( "ERROR", "Couldn't contact LDAP server for authentication" ); - return false; + sleep(1); // Sleep very briefly to try and survive intermittent issues + $ldapDriver = getStaticLdap(); + if ( !$ldapDriver->valid ) { + dbg_error_log( "ERROR", "Couldn't contact LDAP server for authentication" ); + header( sprintf("HTTP/1.1 %d %s", 503, translate("Authentication server unavailable.")) ); + exit(0); + } } $mapping = $c->authenticate_hook['config']['mapping_field'];