No need to retrieve all records by default when getting children. By default sort records by DN until we implemented configurable sorting.

Should help the timeout issues reported in #301
This commit is contained in:
Deon George 2025-03-20 21:03:34 +11:00
parent fd2c5d1286
commit eab4f0427c

View File

@ -247,14 +247,15 @@ final class Server
* @param string $dn * @param string $dn
* @return LDAPCollection|NULL * @return LDAPCollection|NULL
*/ */
public function children(string $dn): ?LDAPCollection public function children(string $dn,array $attrs=['dn']): ?LDAPCollection
{ {
return ($x=(new Entry) return ($x=(new Entry)
->on($this->connection) ->on($this->connection)
->cache(Carbon::now()->addSeconds(Config::get('ldap.cache.time'))) ->cache(Carbon::now()->addSeconds(Config::get('ldap.cache.time')))
->select(['*','hassubordinates']) ->select(array_merge($attrs,['hassubordinates']))
->setDn($dn) ->setDn($dn)
->list() ->list()
->orderBy('dn')
->get()) ? $x : NULL; ->get()) ? $x : NULL;
} }