Load the rootDSE in Server::__construct(), remove basedn from views, and rely on the javascript to get the basedns

This commit is contained in:
2025-06-11 23:08:24 +09:30
parent d61f6168a4
commit 56fcd729e7
8 changed files with 32 additions and 72 deletions

View File

@@ -30,6 +30,8 @@ final class Server
private Collection $matchingrules;
private Collection $objectclasses;
private Entry $rootDSE;
/* ObjectClass Types */
public const OC_STRUCTURAL = 0x01;
public const OC_ABSTRACT = 0x02;
@@ -37,6 +39,8 @@ final class Server
public function __construct()
{
$this->rootDSE = self::rootDSE();
$this->attributetypes = collect();
$this->ldapsyntaxes = collect();
$this->matchingrules = collect();
@@ -66,7 +70,7 @@ final class Server
* @return Collection
* @testedin GetBaseDNTest::testBaseDNExists();
*/
public static function baseDNs(bool $objects=FALSE): Collection
public static function baseDNs(bool $objects=TRUE): Collection
{
try {
$rootdse = self::rootDSE();
@@ -184,7 +188,7 @@ final class Server
foreach (($rootdse->namingcontexts ?: []) as $dn)
$result->push(self::get($dn)->read()->find($dn));
return $result->filter();
return $result->filter()->sort(fn($item)=>$item->sort_key);
});
}
@@ -256,18 +260,6 @@ final class Server
return $rootdse;
}
/**
* Get the Schema DN
*
* @return string
* @throws ObjectNotFoundException
*/
public static function schemaDN(): string
{
return collect(self::rootDSE()->subschemasubentry)
->first();
}
/* METHODS */
/**
@@ -512,6 +504,17 @@ final class Server
return is_null($key) ? $result : $result->get($key);
}
/**
* Get the Schema DN
*
* @return string
* @throws ObjectNotFoundException
*/
public function schemaDN(): string
{
return Arr::get($this->rootDSE->subschemasubentry,0);
}
/**
* Given an OID, return the ldapsyntax for the OID
*