Skip to content

Commit

Permalink
[Web] fix ldap filter if empty
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddleSpl0it committed Feb 20, 2024
1 parent 78e7266 commit d22cafa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions data/web/inc/functions.auth.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d22cafa

Please sign in to comment.