From cbb2b4f5cda6e4765526a7f629bbce494319ab74 Mon Sep 17 00:00:00 2001 From: ralf Date: Wed, 9 Nov 2022 12:32:04 +0100 Subject: [PATCH] get adLDAPUsers::info() to return false again instead of throwing under PHP 8.x --- api/src/Accounts/Ads.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/api/src/Accounts/Ads.php b/api/src/Accounts/Ads.php index acd2765e71..497c36a3f5 100644 --- a/api/src/Accounts/Ads.php +++ b/api/src/Accounts/Ads.php @@ -1719,6 +1719,29 @@ class adLDAPUsers extends \adLDAPUsers } return true; } + + /** + * Find information about the users. Returned in a raw array format from AD. + * + * Reimplemented to deal with InvalidArgumentException caused by calling + * ldap_search or ldap_get_entries under PHP 8.x. + * + * @param string $username The username to query + * @param array $fields Array of parameters to query + * @param bool $isGUID Is the username passed a GUID or a samAccountName + * + * @return array|false false on error + */ + public function info($username, $fields = null, $isGUID = false) + { + try { + return parent::info($username, $fields, $isGUID); + } + catch(\InvalidArgumentException $e) { + // ignore the exceptions caused by calling ldap_get_entries or ldap_get_entries under PHP 8.x + } + return false; + } } /**