From 7a06f5fd64431affdf34d748a957110b4614db94 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Tue, 26 Sep 2023 11:25:19 -0400 Subject: [PATCH] - Added attributes and also Group[C --- src/Attribute/Obj/ObjectClass.php | 16 +++ src/Attribute/Obj/ObjectType.php | 16 +++ src/Common/LdapObject.php | 4 +- src/Entity/Computer.php | 40 +++---- src/Entity/Group.php | 35 ++++++ src/Entity/OrganizationalUnit.php | 40 +++---- src/Entity/User.php | 180 ++++++++---------------------- 7 files changed, 141 insertions(+), 190 deletions(-) create mode 100644 src/Attribute/Obj/ObjectClass.php create mode 100644 src/Attribute/Obj/ObjectType.php create mode 100644 src/Entity/Group.php diff --git a/src/Attribute/Obj/ObjectClass.php b/src/Attribute/Obj/ObjectClass.php new file mode 100644 index 0000000..b5fc5bc --- /dev/null +++ b/src/Attribute/Obj/ObjectClass.php @@ -0,0 +1,16 @@ +type = $type; + } + } +} diff --git a/src/Attribute/Obj/ObjectType.php b/src/Attribute/Obj/ObjectType.php new file mode 100644 index 0000000..a86b8ed --- /dev/null +++ b/src/Attribute/Obj/ObjectType.php @@ -0,0 +1,16 @@ +type = $type; + } + } +} diff --git a/src/Common/LdapObject.php b/src/Common/LdapObject.php index 2b4fd68..bb31327 100644 --- a/src/Common/LdapObject.php +++ b/src/Common/LdapObject.php @@ -82,7 +82,7 @@ class LdapObject { { static::$dump && call_user_func_array(static::$dump, [ $filter, $fields ]); - $this->search = ldap_search($this->connection, $this->dn, $filter['filters'], $filter['fields'], 0, 0); + $this->search = ldap_search($this->connection, $this->dn, $filter['filters'], $filter['fields'] ?? [], 0, 0); $this->rowCount = $this->bufferedRows = ldap_count_entries($this->connection, $this->search); @@ -177,7 +177,7 @@ class LdapObject { public function runUpdateQuery(array $filter, array $dataset) { static::$dump && call_user_func_array(static::$dump, [ $filter, $dataset ]); - + dump($filter, $dataset); if ( false === ( $queryResult = ldap_mod_replace($this->connection, $filter['dn'], $dataset) ) ) { $this->throwLdapException(); } diff --git a/src/Entity/Computer.php b/src/Entity/Computer.php index bd9e54a..86d1770 100644 --- a/src/Entity/Computer.php +++ b/src/Entity/Computer.php @@ -4,50 +4,36 @@ namespace Ulmus\Ldap\Entity; use Ulmus\Ldap\Entity\Field\{ Datetime }; -/** - * @ObjectClass('computer') - */ +use Ulmus\Attribute\Property\Field; + +use Ulmus\Ldap\Attribute\Obj\ObjectClass; + +#[ObjectClass("computer")] class Computer { use \Ulmus\Ldap\EntityTrait; - /** - * @Field - */ + #[Field] public string $samaccountname; - /** - * @Field - */ + #[Field] public string $name; - /** - * @Field - */ + #[Field] public string $description; - /** - * @Field('DNSHostName') - */ + #[Field("DNSHostName")] public string $hostname; - /** - * @Field - */ + #[Field] public string $location; - /** - * @Field - */ + #[Field] public string $operatingSystem; - /** - * @Field - */ + #[Field] public string $operatingSystemServicePack; - /** - * @Field - */ + #[Field] public string $operatingSystemVersion; } \ No newline at end of file diff --git a/src/Entity/Group.php b/src/Entity/Group.php new file mode 100644 index 0000000..c6c37fd --- /dev/null +++ b/src/Entity/Group.php @@ -0,0 +1,35 @@ +name; + } +} \ No newline at end of file diff --git a/src/Entity/OrganizationalUnit.php b/src/Entity/OrganizationalUnit.php index b21da5b..51c498d 100644 --- a/src/Entity/OrganizationalUnit.php +++ b/src/Entity/OrganizationalUnit.php @@ -4,51 +4,37 @@ namespace Ulmus\Ldap\Entity; use Ulmus\Ldap\Entity\Field\{ Datetime }; -/** - * @ObjectClass('organizationalUnit') - */ +use Ulmus\Attribute\Property\Field; + +use Ulmus\Ldap\Attribute\Obj\ObjectClass; + +#[ObjectClass("organizationalUnit")] class OrganizationalUnit { use \Ulmus\Ldap\EntityTrait; - /** - * @Id - */ + #[Field\Id] public string $ou; - /** - * @Field - */ + #[Field] public string $description; - /** - * @Field('name' => "st") - */ + #[Field(name: "st")] public string $state; - /** - * @Field('name' => 'physicalDeliveryOfficeName') - */ + #[Field(name: "physicalDeliveryOfficeName")] public string $officeName; - /** - * @Field('name' => 'postalAddress') - */ + #[Field(name: "postalAddress")] public string $address; - /** - * @Field - */ + #[Field] public string $postalCode; - /** - * @Field - */ + #[Field] public string $telephoneNumber; - /** - * @Field('name' => 'objectGUID') - */ + #[Field(name: "objectGUID")] public string $guid; public function __toString() : string diff --git a/src/Entity/User.php b/src/Entity/User.php index 0719e7c..6267534 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -4,223 +4,135 @@ namespace Ulmus\Ldap\Entity; use Ulmus\Ldap\Entity\Field\{ Datetime, LdapDatetime }; -/** - * @ObjectClass('user') - */ +use Ulmus\Attribute\Property\{Field, Relation\Ignore, Virtual}; + +use Ulmus\Ldap\Attribute\Obj\ObjectClass; + +#[ObjectClass("user")] class User { use \Ulmus\Ldap\EntityTrait; - /** - * @Field - */ + #[Field] public string $samaccountname; - /** - * @Field - */ + #[Field] public string $mail; - /** - * @Field - */ + #[Field] public string $mailNickname; - /** - * @Field('name' => 'givenname') - */ + #[Field(name: "givenname")] public string $firstname; - /** - * @Field('name' => 'sn') - */ + #[Field(name: "sn")] public string $lastname; - /** - * @Field - */ + #[Field] public string $displayName; - /** - * @Field - */ + #[Field] public string $name; - /** - * @Field - */ + #[Field] public string $canonicalName; - /** - * @Field - */ + #[Field] public string $userPrincipalName; - /** - * @Field - */ + #[Field] public string $description; - /** - * @Field('name' => "st") - */ + #[Field(name: "st")] public string $state; - /** - * @Field('name' => 'physicalDeliveryOfficeName') - */ + #[Field(name: "physicalDeliveryOfficeName")] public string $officeName; - /** - * @Field - */ + #[Field] public string $company; - /** - * @Field - */ + #[Field] public string $department; - /** - * @Field - */ + #[Field] public string $telephoneNumber; - /** - * @Field - */ + #[Field] public string $title; - /** - * @Virtual - */ + ##[Virtual] # public ? array $memberOf; - /** - * @Field - */ + #[Field] public int $userAccountControl; - /** - * @Field - */ + #[Field] public string $extensionAttribute1; - /** - * @Field - */ + #[Field] public string $extensionAttribute2; - /** - * @Field - */ + #[Field] public string $extensionAttribute3; - /** - * @Field - */ + #[Field] public string $extensionAttribute4; - /** - * @Field - */ + #[Field] public string $extensionAttribute5; - /** - * @Field - */ + #[Field] public string $extensionAttribute6; - /** - * @Field - */ + #[Field] public string $extensionAttribute7; - /** - * @Field - */ + #[Field] public string $extensionAttribute8; - /** - * @Field - */ + #[Field] public string $extensionAttribute9; - /** - * @Field - */ + #[Field] public string $extensionAttribute10; - /** - * @Field - */ + #[Field] public string $extensionAttribute11; - /** - * @Field - */ + #[Field] public string $extensionAttribute12; - /** - * @Field - */ + #[Field] public string $extensionAttribute13; - /** - * @Field - */ + #[Field] public string $extensionAttribute14; - /** - * @Field - */ + #[Field] public string $extensionAttribute15; - /** - * @Field - */ + #[Field] public int $logonCount; - /** - * @Field('name' => 'unicodePwd') - */ + #[Field(name: "unicodePwd")] public string $unicodePassword; - /** - * @Field - */ + #[Field] public string $userPassword; - /** - * @Field - */ + #[Field] public string $scriptPath; - /** - * @Field - */ + #[Field] public string $sid; - /** - * @Field - */ + #[Field] public string $targetAddress; - /** - * @Field('name' => "lastLogon", 'readonly' => true) - */ + #[Field(name: "lastLogon", readonly: true)] public LdapDatetime $lastLogon; - - /** - * @Field('name' => "whenChanged", 'readonly' => true) - * / - public LdapDatetime $updatedAt; - - /** - * @Field('name' => "whenCreated", 'readonly' => true) - * / - public LdapDatetime $createdAt; */ - + public function __toString() : string { return implode(' ', array_filter([ $this->firstname ?? "", $this->lastname ?? "" ])) ?: ( $this->displayName ?? "" );