Further to eab4f04 we need some attributes to render tree icons

This commit is contained in:
Deon George 2025-03-22 22:56:22 +11:00
parent a57ee78492
commit 5bb573100b
2 changed files with 14 additions and 5 deletions

View File

@ -209,7 +209,8 @@ final class Server
/** /**
* Obtain the rootDSE for the server, that gives us server information * 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 * @return Entry|null
* @throws ObjectNotFoundException * @throws ObjectNotFoundException
* @testedin TranslateOidTest::testRootDSE(); * @testedin TranslateOidTest::testRootDSE();
@ -230,7 +231,7 @@ final class Server
/** /**
* Get the Schema DN * Get the Schema DN
* *
* @param $connection * @param string|null $connection
* @return string * @return string
* @throws ObjectNotFoundException * @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. * Query the server for a DN and return its children and if those children have children.
* *
* @param string $dn * @param string $dn
* @param array $attrs
* @return LDAPCollection|NULL * @return LDAPCollection|NULL
*/ */
public function children(string $dn,array $attrs=['dn']): ?LDAPCollection public function children(string $dn,array $attrs=['dn']): ?LDAPCollection
@ -252,7 +254,10 @@ final class Server
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(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) ->setDn($dn)
->list() ->list()
->orderBy('dn') ->orderBy('dn')
@ -529,7 +534,6 @@ final class Server
* *
* @param string $oid * @param string $oid
* @return LDAPSyntax|null * @return LDAPSyntax|null
* @throws InvalidUsage
*/ */
public function schemaSyntaxName(string $oid): ?LDAPSyntax public function schemaSyntaxName(string $oid): ?LDAPSyntax
{ {

View File

@ -14,6 +14,11 @@ use App\Classes\LDAP\Export\LDIF;
use App\Exceptions\Import\AttributeException; use App\Exceptions\Import\AttributeException;
use App\Exceptions\InvalidUsage; use App\Exceptions\InvalidUsage;
/**
* An Entry in an LDAP server
*
* @notes https://ldap.com/ldap-dns-and-rdns
*/
class Entry extends Model class Entry extends Model
{ {
private const TAG_CHARS = 'a-zA-Z0-9-'; private const TAG_CHARS = 'a-zA-Z0-9-';
@ -480,7 +485,7 @@ class Entry extends Model
return 'fas fa-theater-masks'; return 'fas fa-theater-masks';
elseif (in_array('country',$objectclasses)) 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)) elseif (in_array('device',$objectclasses))
return 'fas fa-mobile-alt'; return 'fas fa-mobile-alt';