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...
This commit is contained in:
Andrew McMillan 2012-05-14 22:57:52 +12:00
parent 724a549502
commit a267a25165

View File

@ -292,10 +292,15 @@ function sync_user_from_LDAP( Principal &$principal, $mapping, $ldap_values ) {
function LDAP_check($username, $password ){
global $c;
$ldapDriver = getStaticLdap();
if ( !$ldapDriver->valid ) {
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" );
return false;
header( sprintf("HTTP/1.1 %d %s", 503, translate("Authentication server unavailable.")) );
exit(0);
}
}
$mapping = $c->authenticate_hook['config']['mapping_field'];