Skip to content

Commit

Permalink
[Web] apply LDAP filter
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddleSpl0it committed Feb 23, 2024
1 parent 766c270 commit 010d898
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions data/conf/phpfpm/crons/ldap-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ function logMsg($priority, $message, $task = "LDAP Sync") {
fclose($lock_file_handle);

// Get ldap users
$response = $iam_provider->query()
->where($iam_settings['username_field'], "*")
$ldap_query = $iam_provider->query();
if (!empty($iam_settings['filter'])) {
$ldap_query = $ldap_query->rawFilter($iam_settings['filter']);
}
$response = $ldap_query->where($iam_settings['username_field'], "*")
->where($iam_settings['attribute_field'], "*")
->select([$iam_settings['username_field'], $iam_settings['attribute_field'], 'displayname'])
->paginate($max);
Expand Down
8 changes: 4 additions & 4 deletions data/web/inc/functions.auth.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,12 @@ function ldap_mbox_login($user, $pass, $iam_settings, $extra = null){
}

try {
$ldap_query = $iam_provider->query()
->where($iam_settings['username_field'], '=', $user)
->select([$iam_settings['username_field'], $iam_settings['attribute_field'], 'displayname', 'distinguishedname']);
$ldap_query = $iam_provider->query();
if (!empty($iam_settings['filter'])) {
$ldap_query = $ldap_query->whereRaw($iam_settings['filter']);
$ldap_query = $ldap_query->rawFilter($iam_settings['filter']);
}
$ldap_query = $ldap_query->where($iam_settings['username_field'], '=', $user)
->select([$iam_settings['username_field'], $iam_settings['attribute_field'], 'displayname', 'distinguishedname']);

$user_res = $ldap_query->firstOrFail();
} catch (Exception $e) {
Expand Down

0 comments on commit 010d898

Please sign in to comment.