use additional LDAP filter for search

This commit is contained in:
Roland Gruber 2020-07-18 20:33:36 +02:00
parent 2698995cc2
commit 4158ebb91d
1 changed files with 10 additions and 0 deletions

View File

@ -802,6 +802,16 @@ function searchLDAPByFilter($filter, $attributes, $scopes, $attrsOnly = false) {
$typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypesForScopes($scopes);
foreach ($types as $type) {
$additionalFilter = $type->getAdditionalLdapFilter();
if (!empty($additionalFilter)) {
if (strpos($additionalFilter, '(') !== 0) {
$additionalFilter = '(' . $additionalFilter . ')';
}
if (strpos($filter, '(') !== 0) {
$filter = '(' . $filter . ')';
}
$filter = '(&' . $additionalFilter . $filter . ')';
}
// search LDAP
$entries = searchLDAPPaged($_SESSION['ldap']->server(), escapeDN($type->getSuffix()),
$filter, $attributes, $readAttributesOnly, $_SESSION['config']->get_searchLimit());