handle not available AD or LDAP connection with an exception, caught and just displayed within setup, so one can change ip or credentials

This commit is contained in:
Ralf Becker 2013-06-23 09:58:08 +00:00
parent c55d30dd07
commit c44be3ee6d
4 changed files with 10 additions and 9 deletions

View File

@ -102,6 +102,7 @@ class accounts_ads
* Constructor
*
* @param accounts $frontend reference to the frontend class, to be able to call it's methods if needed
* @throws adLDAPException
* @return accounts_ldap
*/
function __construct(accounts $frontend)

View File

@ -128,7 +128,7 @@ class accounts_ldap
// enable the caching in the session, done by the accounts class extending this class.
$this->use_session_cache = true;
$this->ldap = new ldap();
$this->ldap = new ldap(true);
$this->ds = $this->ldap->ldapConnect($this->frontend->config['ldap_host'],
$this->frontend->config['ldap_root_dn'],$this->frontend->config['ldap_root_pw']);

View File

@ -1548,7 +1548,7 @@ function _egw_log_exception(Exception $e,&$headline=null)
// which outputs the error_log to stderr and therefore output it twice to the user
if(isset($_SERVER['HTTP_HOST']) || $GLOBALS['egw_info']['flags']['no_exception_handler'] !== 'cli')
{
error_log($headline.': '.$e->getMessage());
error_log($headline.' ('.get_class($e).'): '.$e->getMessage());
foreach(explode("\n",$e->getTraceAsString()) as $line) error_log($line);
error_log('# Instance='.$GLOBALS['egw_info']['user']['domain'].', User='.$GLOBALS['egw_info']['user']['account_lid'].', URL='.
($_SERVER['HTTPS']?'https://':'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);

View File

@ -1005,15 +1005,15 @@ class setup
$GLOBALS['egw_info']['server'][$row['config_name']] = $config[$row['config_name']] = $row['config_value'];
}
}
try {
$this->accounts = new accounts($config);
if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts;
accounts::cache_invalidate(); // the cache is shared for all instances of the class
if($this->accounts->backend instanceof accounts_ldap && !$this->accounts->backend->ds)
{
printf("<b>Error: Error connecting to LDAP server %s!</b><br>",$config['ldap_host']);
}
catch (Exception $e) {
echo "<p><b>".$e->getMessage()."</b></p>\n";
return false;
}
if (!isset($GLOBALS['egw']->accounts)) $GLOBALS['egw']->accounts = $this->accounts;
accounts::cache_invalidate(); // the cache is shared for all instances of the class
}
return true;
}