Skip to content

Commit fcd8ddf

Browse files
author
robin.kluth
committed
* Added $allDomainsHaveToBeReachable for searchUser
1 parent 0e4c7bf commit fcd8ddf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/LdapAuth.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,11 @@ public function fetchUserData($attributes = "")
317317
* @param string|null $searchFilter Filter string. Set %searchFor% als placeholder to search for $searchFor
318318
* @param integer $domainKey You can provide integer domainkey, this is then used as target domain! Otherwise it searches in all domains
319319
* @param bool $onlyActiveAccounts SHould the search result only contain active accounts? => https://www.der-windows-papst.de/2016/12/18/active-directory-useraccountcontrol-values/
320-
* @return array An Array with the results, indexed by their SID
320+
* @param bool $allDomainsHaveToBeReachable True: All configured domains need to be reachable in order to get a result. If one is not reachable, false will be returned
321+
* @return array|false An Array with the results, indexed by their SID - false if an ERROR occured!
321322
* @throws \InvalidArgumentException
322323
*/
323-
public function searchUser(string $searchFor, $attributes = "", $searchFilter = "", $domainKey = false, $onlyActiveAccounts = false)
324+
public function searchUser(string $searchFor, $attributes = "", $searchFilter = "", bool $domainKey = false, bool $onlyActiveAccounts = false, bool $allDomainsHaveToBeReachable = false)
324325
{
325326

326327
if (empty($attributes)) {
@@ -364,6 +365,11 @@ public function searchUser(string $searchFor, $attributes = "", $searchFilter =
364365
} else {
365366
Yii::error('LDAP Connect or Bind error (' . ldap_errno($this->_l) . ' - ' . ldap_error($this->_l) . ') on ' . $domain['hostname'] . ', skipping...');
366367
}
368+
if ($allDomainsHaveToBeReachable) {
369+
Yii::warning('Abort search, due to error and $allDomainsHaveToBeReachable is true');
370+
return false;
371+
}
372+
continue;
367373
}
368374

369375
$searchFilter = str_replace("%searchFor%", addslashes($searchFor), $searchFilter);

0 commit comments

Comments
 (0)