From 73f66eb282ab96730715a51428d122306ff1f23f Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 3 Jul 2025 18:34:35 +0800 Subject: [PATCH] Tag baseDNs as bases, and show their full DN in the tree --- app/Classes/LDAP/Server.php | 8 +++++--- app/Http/Controllers/AjaxController.php | 2 +- app/Ldap/Entry.php | 11 +++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Classes/LDAP/Server.php b/app/Classes/LDAP/Server.php index 74341ce1..5f2f5576 100644 --- a/app/Classes/LDAP/Server.php +++ b/app/Classes/LDAP/Server.php @@ -181,8 +181,11 @@ final class Server $result = collect(); // @note: Incase our rootDSE didnt return a namingcontext, we'll have no base DNs - foreach ($namingcontexts as $dn) - $result->push(self::get($dn)->read()->find($dn)); + foreach ($namingcontexts as $dn) { + $o = self::get($dn)->read()->find($dn); + $o->setBase(); + $result->push($o); + } return $result->filter()->sort(fn($item)=>$item->sort_key); }); @@ -501,7 +504,6 @@ final class Server * Get the Schema DN * * @return string - * @throws ObjectNotFoundException */ public function schemaDN(): string { diff --git a/app/Http/Controllers/AjaxController.php b/app/Http/Controllers/AjaxController.php index 0b57a6df..8bc26a34 100644 --- a/app/Http/Controllers/AjaxController.php +++ b/app/Http/Controllers/AjaxController.php @@ -24,7 +24,7 @@ class AjaxController extends Controller { return Server::baseDNs() ->map(fn($item)=> [ - 'title'=>$item->getRdn(), + 'title'=>$item->is_base ? $item->getDn() : $item->getRdn(), 'item'=>$item->getDNSecure(), 'lazy'=>TRUE, 'icon'=>'fa-fw fas fa-sitemap', diff --git a/app/Ldap/Entry.php b/app/Ldap/Entry.php index e3a758af..5923a91a 100644 --- a/app/Ldap/Entry.php +++ b/app/Ldap/Entry.php @@ -39,6 +39,7 @@ class Entry extends Model // For new entries, this is the container that this entry will be stored in private string $rdnbase; + private(set) bool $is_base; /* OVERRIDES */ @@ -574,6 +575,16 @@ class Entry extends Model return [$attribute,$tags]; } + /** + * Is this entry a baseDN + * + * @return void + */ + public function setBase(): void + { + $this->is_base = TRUE; + } + public function setRDNBase(string $bdn): void { if ($this->exists)