- Updated to match Notes-2.x
This commit is contained in:
1 parent
4b9a162696
commit
5cd0d13404
14 files changed
+243
-70
No files matched your search
+10
-3
@@ -4,9 +4,12 @@ namespace Ulmus\Ldap\Entity;
|
||||
|
||||
use Ulmus\Ldap\Entity\Field\{ Datetime };
|
||||
|
||||
use Ulmus\Attribute\Property\Field;
|
||||
use Ulmus\Attribute\Property\{Field, Filter, Relation, Virtual};
|
||||
|
||||
use Ulmus\EntityCollection;
|
||||
use Ulmus\Ldap\Attribute\Obj\ObjectClass;
|
||||
use Ulmus\Ldap\Repository;
|
||||
use Ulmus\Repository\RepositoryInterface;
|
||||
|
||||
#[ObjectClass("group")]
|
||||
class Group
|
||||
@@ -17,10 +20,10 @@ class Group
|
||||
public string $samaccountname;
|
||||
|
||||
#[Field]
|
||||
public array $members;
|
||||
public string $name;
|
||||
|
||||
#[Field]
|
||||
public string $name;
|
||||
public string $description;
|
||||
|
||||
#[Field]
|
||||
public string $canonicalName;
|
||||
@@ -28,6 +31,10 @@ class Group
|
||||
#[Field(name: "objectGUID")]
|
||||
public string $guid;
|
||||
|
||||
# You will need to override this method in your entity because an adapter needs to be set for the User entity.
|
||||
#[Relation(type: Relation\RelationTypeEnum::oneToMany, key: 'dn', foreignKey: "memberOf", entity: User::class)]
|
||||
public EntityCollection $members;
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->name;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Ldap\Entity;
|
||||
|
||||
use Ulmus\Ldap\Entity\Field\{ Datetime };
|
||||
|
||||
use Ulmus\Attribute\Property\{Field, Filter, Relation, Virtual};
|
||||
|
||||
use Ulmus\EntityCollection;
|
||||
use Ulmus\Ldap\Attribute\Obj\ObjectClass;
|
||||
use Ulmus\Ldap\Repository;
|
||||
use Ulmus\Repository\RepositoryInterface;
|
||||
|
||||
#[ObjectClass("group")]
|
||||
class GroupMember
|
||||
{
|
||||
use \Ulmus\Ldap\EntityTrait;
|
||||
|
||||
#[Field]
|
||||
public string $member;
|
||||
}
|
||||
+8
-3
@@ -61,8 +61,8 @@ class User
|
||||
#[Field]
|
||||
public string $title;
|
||||
|
||||
##[Field(readonly:true)]
|
||||
# public ? array $memberOf;
|
||||
#[Field(readonly:true)]
|
||||
public ? array $memberOf;
|
||||
|
||||
##[Field(readonly:true)]
|
||||
#public ? array $proxyAddresses;
|
||||
@@ -149,12 +149,17 @@ class User
|
||||
|
||||
public function memberOfGroup() : array
|
||||
{
|
||||
$arr = array_map(fn($e) => explode('=', explode(',', $e)[0])[1], $this->memberOf);
|
||||
$arr = array_map(fn($e) => explode('=', explode(',', $e)[0])[1], (array) $this->memberOf);
|
||||
usort($arr, 'strcasecmp');
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function isMemberOf(string $name) : bool
|
||||
{
|
||||
return in_array(strtolower($name), array_map('strtolower', $this->memberOfGroup()), true);
|
||||
}
|
||||
|
||||
public function brokenMigration() : bool
|
||||
{
|
||||
if ( empty($this->targetAddress) ) {
|
||||
|
||||
Reference in new issue
Block a user