AD Auth PHP8.1 fixes (#14215)

This commit is contained in:
Tony Murray
2022-08-18 21:47:14 -05:00
committed by GitHub
parent 59fc562d99
commit 6e8224565f
2 changed files with 15 additions and 15 deletions

View File

@@ -196,7 +196,7 @@ trait ActiveDirectoryCommon
];
}
public function getUser($user_id)
public function getUser($user_id): array
{
$connection = $this->getConnection();
$domain_sid = $this->getDomainSid();
@@ -204,16 +204,19 @@ trait ActiveDirectoryCommon
$search_filter = "(&(objectcategory=person)(objectclass=user)(objectsid=$domain_sid-$user_id))";
$attributes = ['samaccountname', 'displayname', 'objectsid', 'mail'];
$search = ldap_search($connection, Config::get('auth_ad_base_dn'), $search_filter, $attributes);
$entry = ldap_get_entries($connection, $search);
if (isset($entry[0]['samaccountname'][0])) {
return $this->userFromAd($entry[0]);
if ($search !== false) {
$entry = ldap_get_entries($connection, $search);
if (isset($entry[0]['samaccountname'][0])) {
return $this->userFromAd($entry[0]);
}
}
return [];
}
protected function getDomainSid()
protected function getDomainSid(): string
{
$connection = $this->getConnection();
@@ -226,6 +229,13 @@ trait ActiveDirectoryCommon
'(objectClass=*)',
['objectsid']
);
if ($search === false) {
\Log::debug('AD Auth: Could not determine domain SID');
return '';
}
$entry = ldap_get_entries($connection, $search);
return substr($this->sidFromLdap($entry[0]['objectsid'][0]), 0, 41);

View File

@@ -1005,11 +1005,6 @@ parameters:
count: 1
path: LibreNMS/Authentication/ADAuthorizationAuthorizer.php
-
message: "#^Method LibreNMS\\\\Authentication\\\\ADAuthorizationAuthorizer\\:\\:getDomainSid\\(\\) has no return type specified\\.$#"
count: 1
path: LibreNMS/Authentication/ADAuthorizationAuthorizer.php
-
message: "#^Method LibreNMS\\\\Authentication\\\\ADAuthorizationAuthorizer\\:\\:getFullname\\(\\) has no return type specified\\.$#"
count: 1
@@ -1125,11 +1120,6 @@ parameters:
count: 1
path: LibreNMS/Authentication/ActiveDirectoryAuthorizer.php
-
message: "#^Method LibreNMS\\\\Authentication\\\\ActiveDirectoryAuthorizer\\:\\:getDomainSid\\(\\) has no return type specified\\.$#"
count: 1
path: LibreNMS/Authentication/ActiveDirectoryAuthorizer.php
-
message: "#^Method LibreNMS\\\\Authentication\\\\ActiveDirectoryAuthorizer\\:\\:getFullname\\(\\) has no return type specified\\.$#"
count: 1