mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: AD Auth defer connection until it is needed (#7768)
* refactor: AD Auth defer connection until it is needed Nice error if php-ldap is missing instead of http 500. * Add the same error when ldap is missing to other auth methods. Not as graceful looking in the authorizers since they do not defer connection.
This commit is contained in:
@@ -15,6 +15,10 @@ class ADAuthorizationAuthorizer extends AuthorizerBase
|
||||
$_SESSION['username'] = '';
|
||||
}
|
||||
|
||||
if (!function_exists('ldap_connect')) {
|
||||
throw new AuthenticationException("PHP does not support LDAP, please install or enable the PHP LDAP extension.");
|
||||
}
|
||||
|
||||
// Disable certificate checking before connect if required
|
||||
if (Config::has('auth_ad_check_certificates') &&
|
||||
Config::get('auth_ad_check_certificates') == 0) {
|
||||
@@ -24,8 +28,7 @@ class ADAuthorizationAuthorizer extends AuthorizerBase
|
||||
// Set up connection to LDAP server
|
||||
$this->ldap_connection = @ldap_connect(Config::get('auth_ad_url'));
|
||||
if (! $this->ldap_connection) {
|
||||
echo '<h2>Fatal error while connecting to AD url ' . Config::get('auth_ad_url') . ': ' . ldap_error($this->ldap_connection) . '</h2>';
|
||||
exit;
|
||||
throw new AuthenticationException('Fatal error while connecting to AD url ' . Config::get('auth_ad_url') . ': ' . ldap_error($this->ldap_connection));
|
||||
}
|
||||
|
||||
// disable referrals and force ldap version to 3
|
||||
|
Reference in New Issue
Block a user