mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
AD Auth PHP8.1 fixes (#14215)
This commit is contained in:
@@ -196,7 +196,7 @@ trait ActiveDirectoryCommon
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUser($user_id)
|
public function getUser($user_id): array
|
||||||
{
|
{
|
||||||
$connection = $this->getConnection();
|
$connection = $this->getConnection();
|
||||||
$domain_sid = $this->getDomainSid();
|
$domain_sid = $this->getDomainSid();
|
||||||
@@ -204,16 +204,19 @@ trait ActiveDirectoryCommon
|
|||||||
$search_filter = "(&(objectcategory=person)(objectclass=user)(objectsid=$domain_sid-$user_id))";
|
$search_filter = "(&(objectcategory=person)(objectclass=user)(objectsid=$domain_sid-$user_id))";
|
||||||
$attributes = ['samaccountname', 'displayname', 'objectsid', 'mail'];
|
$attributes = ['samaccountname', 'displayname', 'objectsid', 'mail'];
|
||||||
$search = ldap_search($connection, Config::get('auth_ad_base_dn'), $search_filter, $attributes);
|
$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])) {
|
if ($search !== false) {
|
||||||
return $this->userFromAd($entry[0]);
|
$entry = ldap_get_entries($connection, $search);
|
||||||
|
|
||||||
|
if (isset($entry[0]['samaccountname'][0])) {
|
||||||
|
return $this->userFromAd($entry[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getDomainSid()
|
protected function getDomainSid(): string
|
||||||
{
|
{
|
||||||
$connection = $this->getConnection();
|
$connection = $this->getConnection();
|
||||||
|
|
||||||
@@ -226,6 +229,13 @@ trait ActiveDirectoryCommon
|
|||||||
'(objectClass=*)',
|
'(objectClass=*)',
|
||||||
['objectsid']
|
['objectsid']
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($search === false) {
|
||||||
|
\Log::debug('AD Auth: Could not determine domain SID');
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
$entry = ldap_get_entries($connection, $search);
|
$entry = ldap_get_entries($connection, $search);
|
||||||
|
|
||||||
return substr($this->sidFromLdap($entry[0]['objectsid'][0]), 0, 41);
|
return substr($this->sidFromLdap($entry[0]['objectsid'][0]), 0, 41);
|
||||||
|
@@ -1005,11 +1005,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: LibreNMS/Authentication/ADAuthorizationAuthorizer.php
|
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\\.$#"
|
message: "#^Method LibreNMS\\\\Authentication\\\\ADAuthorizationAuthorizer\\:\\:getFullname\\(\\) has no return type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
@@ -1125,11 +1120,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: LibreNMS/Authentication/ActiveDirectoryAuthorizer.php
|
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\\.$#"
|
message: "#^Method LibreNMS\\\\Authentication\\\\ActiveDirectoryAuthorizer\\:\\:getFullname\\(\\) has no return type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
Reference in New Issue
Block a user