From a0d03045791d1a7a2ae869fea7b7f932f20405da Mon Sep 17 00:00:00 2001 From: fiwswe <53953985+fiwswe@users.noreply.github.com> Date: Mon, 3 Jul 2023 11:45:23 +0200 Subject: [PATCH] return false in getUserData in case of errors The interface contract for the method getUserData does not allow an empty array to be returned. --- lib/plugins/authad/auth.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/plugins/authad/auth.php b/lib/plugins/authad/auth.php index e47ad97fc..d5fd52805 100644 --- a/lib/plugins/authad/auth.php +++ b/lib/plugins/authad/auth.php @@ -198,7 +198,7 @@ class auth_plugin_authad extends AuthPlugin * @author James Van Lommel * @param string $user * @param bool $requireGroups (optional) - ignored, groups are always supplied by this plugin - * @return array + * @return array|false */ public function getUserData($user, $requireGroups = true) { @@ -207,9 +207,8 @@ class auth_plugin_authad extends AuthPlugin global $ID; global $INPUT; $adldap = $this->initAdLdap($this->getUserDomain($user)); - if (!$adldap) return []; - - if ($user == '') return []; + if (!$adldap) return false; + if ($user == '') return false; $fields = ['mail', 'displayname', 'samaccountname', 'lastpwd', 'pwdlastset', 'useraccountcontrol']; @@ -221,7 +220,7 @@ class auth_plugin_authad extends AuthPlugin //get info for given user $result = $adldap->user()->info($this->getUserName($user), $fields); if ($result == false) { - return []; + return false; } //general user info @@ -249,10 +248,12 @@ class auth_plugin_authad extends AuthPlugin foreach ($info['grps'] as $ndx => $group) { $info['grps'][$ndx] = $this->cleanGroup($group); } + } else { + $info['grps'] = []; } // always add the default group to the list of groups - if (!is_array($info['grps']) || !in_array($conf['defaultgroup'], $info['grps'])) { + if (!in_array($conf['defaultgroup'], $info['grps'])) { $info['grps'][] = $conf['defaultgroup']; } -- 2.11.4.GIT