From d22cafacc86ab9ebe4a3e9f20924fc1a27c84332 Mon Sep 17 00:00:00 2001 From: FreddleSpl0it Date: Tue, 20 Feb 2024 11:21:25 +0100 Subject: [PATCH] [Web] fix ldap filter if empty --- data/web/inc/functions.auth.inc.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/data/web/inc/functions.auth.inc.php b/data/web/inc/functions.auth.inc.php index d325c0723..6075ab764 100644 --- a/data/web/inc/functions.auth.inc.php +++ b/data/web/inc/functions.auth.inc.php @@ -493,11 +493,14 @@ function ldap_mbox_login($user, $pass, $iam_settings, $extra = null){ } try { - $user_res = $iam_provider->query() + $ldap_query = $iam_provider->query() ->where($iam_settings['username_field'], '=', $user) - ->whereRaw($iam_settings['filter']) - ->select([$iam_settings['username_field'], $iam_settings['attribute_field'], 'displayname', 'distinguishedname']) - ->firstOrFail(); + ->select([$iam_settings['username_field'], $iam_settings['attribute_field'], 'displayname', 'distinguishedname']); + if (!empty($iam_settings['filter'])) { + $ldap_query = $ldap_query->whereRaw($iam_settings['filter']); + } + + $user_res = $ldap_query->firstOrFail(); } catch (Exception $e) { return false; }