Skip to content

Commit b607bf9

Browse files
author
Robin Kluth
committed
feat(groups): Support baseDn and add dn to default searchFilter
1 parent 3ee2f1c commit b607bf9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/LdapAuth.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,11 @@ public function searchUser(?string $searchFor, ?array $attributes = [], ?string
628628
* @param int|null $domainKey
629629
* @param bool $onlyActiveAccounts
630630
* @param bool $allDomainsHaveToBeReachable
631+
* @param string|null $baseDn
631632
* @return array|false
632633
* @throws ErrorException
633634
*/
634-
public function searchGroup(?string $searchFor, array $groupAttributes = ['dn', 'member'], ?array $userAttributes = ['dn', 'samaccountname', 'mail'], bool $returnMembers = false, ?string $searchFilter = "", ?int $domainKey = null, bool $onlyActiveAccounts = false, bool $allDomainsHaveToBeReachable = false)
635+
public function searchGroup(?string $searchFor, array $groupAttributes = ['dn', 'member'], ?array $userAttributes = ['dn', 'samaccountname', 'mail'], bool $returnMembers = false, ?string $searchFilter = "", ?int $domainKey = null, bool $onlyActiveAccounts = false, bool $allDomainsHaveToBeReachable = false, $baseDn = null)
635636
{
636637
if (!in_array('dn', $groupAttributes)) {
637638
$groupAttributes[] = 'dn';
@@ -641,10 +642,10 @@ public function searchGroup(?string $searchFor, array $groupAttributes = ['dn',
641642
}
642643

643644
if (empty($searchFilter)) {
644-
$searchFilter = "(&(objectCategory=group) (|(objectSid=%searchFor%)(cn=%searchFor%)))";
645+
$searchFilter = "(&(objectCategory=group) (|(objectSid=%searchFor%)(cn=%searchFor%)(dn=%searchFor%)))";
645646
}
646647

647-
$groups = $this->searchUser($searchFor, $groupAttributes, $searchFilter, $domainKey, $onlyActiveAccounts, $allDomainsHaveToBeReachable);
648+
$groups = $this->searchUser($searchFor, $groupAttributes, $searchFilter, $domainKey, $onlyActiveAccounts, $allDomainsHaveToBeReachable, $baseDn);
648649

649650
if (!$returnMembers) {
650651
return $groups;

0 commit comments

Comments
 (0)