Skip to content

Commit

Permalink
More ldap failure checks
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Jun 18, 2024
1 parent c202b65 commit bdfdd7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LibreNMS/Authentication/ADAuthorizationAuthorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function userExists($username, $throw_exception = false)
$this->userFilter($username),
['samaccountname']
);
if ($search === false) {
throw new AuthenticationException('User search failed: ' . ldap_error($this->ldap_connection));
}
$entries = ldap_get_entries($this->ldap_connection, $search);

if ($entries['count']) {
Expand Down Expand Up @@ -151,6 +154,9 @@ public function getUserid($username)
$this->userFilter($username),
$attributes
);
if ($search === false) {
throw new AuthenticationException('Role search failed: ' . ldap_error($this->ldap_connection));
}
$entries = ldap_get_entries($this->ldap_connection, $search);

if ($entries['count']) {
Expand Down
3 changes: 3 additions & 0 deletions LibreNMS/Authentication/LdapAuthorizationAuthorizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function userExists($username, $throw_exception = false)

$filter = '(' . Config::get('auth_ldap_prefix') . $username . ')';
$search = ldap_search($this->ldap_connection, trim(Config::get('auth_ldap_suffix'), ','), $filter);
if ($search === false) {
throw new AuthenticationException('User search failed: ' . ldap_error($this->ldap_connection));
}
$entries = ldap_get_entries($this->ldap_connection, $search);
if ($entries['count']) {
/*
Expand Down

0 comments on commit bdfdd7e

Please sign in to comment.