From 5bb573100b4b9f8de869e83ee9f8bb02c3278ad3 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sat, 22 Mar 2025 22:56:22 +1100 Subject: [PATCH] Further to eab4f04 we need some attributes to render tree icons --- app/Classes/LDAP/Server.php | 12 ++++++++---- app/Ldap/Entry.php | 7 ++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php index 017c9cbd..f6b89cff 100644 --- a/app/Classes/LDAP/Server.php +++ b/app/Classes/LDAP/Server.php @@ -209,7 +209,8 @@ final class Server /** * Obtain the rootDSE for the server, that gives us server information * - * @param null $connection + * @param string|null $connection + * @param Carbon|null $cachetime * @return Entry|null * @throws ObjectNotFoundException * @testedin TranslateOidTest::testRootDSE(); @@ -230,7 +231,7 @@ final class Server /** * Get the Schema DN * - * @param $connection + * @param string|null $connection * @return string * @throws ObjectNotFoundException */ @@ -245,6 +246,7 @@ final class Server * Query the server for a DN and return its children and if those children have children. * * @param string $dn + * @param array $attrs * @return LDAPCollection|NULL */ public function children(string $dn,array $attrs=['dn']): ?LDAPCollection @@ -252,7 +254,10 @@ final class Server return ($x=(new Entry) ->on($this->connection) ->cache(Carbon::now()->addSeconds(Config::get('ldap.cache.time'))) - ->select(array_merge($attrs,['hassubordinates'])) + ->select(array_merge($attrs,[ + 'hassubordinates', // Needed for the tree to know if an entry has children + 'c' // Needed for the tree to show icons for countries + ])) ->setDn($dn) ->list() ->orderBy('dn') @@ -529,7 +534,6 @@ final class Server * * @param string $oid * @return LDAPSyntax|null - * @throws InvalidUsage */ public function schemaSyntaxName(string $oid): ?LDAPSyntax { diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index adb7103d..6754f38a 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -14,6 +14,11 @@ use App\Classes\LDAP\Export\LDIF; use App\Exceptions\Import\AttributeException; use App\Exceptions\InvalidUsage; +/** + * An Entry in an LDAP server + * + * @notes https://ldap.com/ldap-dns-and-rdns + */ class Entry extends Model { private const TAG_CHARS = 'a-zA-Z0-9-'; @@ -480,7 +485,7 @@ class Entry extends Model return 'fas fa-theater-masks'; elseif (in_array('country',$objectclasses)) - return sprintf('flag %s',strtolower(Arr::get($this->c,0))); + return sprintf('flag %s',strtolower(Arr::get($this->c ?: [],0))); elseif (in_array('device',$objectclasses)) return 'fas fa-mobile-alt';