- A lot of work done to stabilize implemented features ; still a lot of thing to be done!
This commit is contained in:
1 parent
a0363ebb71
commit
b681f245c0
8 files changed
+193
-18
No files matched your search
@@ -8,5 +8,4 @@ class Datetime extends \Ulmus\Entity\Field\Datetime {
|
||||
{
|
||||
return new static(substr($arguments[0], 0, 8));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Ldap\Entity\Field;
|
||||
|
||||
class LdapDatetime extends Datetime {
|
||||
|
||||
public const DATETIME_EPOCH_DIFF = 11644477200;
|
||||
|
||||
public function load(...$arguments)
|
||||
{
|
||||
if (is_numeric($arguments[0])) {
|
||||
return static::createDateTimeFromSystemTime($arguments[0]);
|
||||
}
|
||||
|
||||
return parent::load(...$arguments);
|
||||
}
|
||||
|
||||
# https://stackoverflow.com/a/64918390
|
||||
public static function createDateTimeFromSystemTime($time, $basis = '1601-01-01 00:00:00', $resolution = 1.E-7, $timeZone = 'UTC') : \DateTimeInterface
|
||||
{
|
||||
return new static((new \DateTime($basis.' UTC'))
|
||||
->modify(round($time * $resolution ).' Seconds')
|
||||
->setTimeZone(new \DateTimeZone($timeZone))
|
||||
->format('Y-m-d H:i:s')
|
||||
);
|
||||
}
|
||||
|
||||
public function save()
|
||||
{
|
||||
return (string) $this->getSystemTime();
|
||||
}
|
||||
|
||||
public function getSystemTime($basis = '1601-01-01 00:00:00', $resolution = 1.E7, $timeZone = 'UTC') : int
|
||||
{
|
||||
$interval = (new \DateTime('1970-01-01 00:00:00 UTC'))->diff(new \DateTime($basis.' UTC'));
|
||||
|
||||
$diff = $interval->days * 86400 + $interval->h * 3600 + $interval->i * 60 + $interval->s;
|
||||
|
||||
return ( $this->setTimeZone(new \DateTimeZone($timeZone))->getTimestamp() + $diff ) * $resolution;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,11 @@ class OrganizationalUnit
|
||||
*/
|
||||
public string $telephoneNumber;
|
||||
|
||||
/**
|
||||
* @Field('name' => 'objectGUID')
|
||||
*/
|
||||
public string $guid;
|
||||
|
||||
public function __toString() : string
|
||||
{
|
||||
return $this->ou;
|
||||
|
||||
+85
-7
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Ulmus\Ldap\Entity;
|
||||
|
||||
use Ulmus\Ldap\Entity\Field\{ Datetime };
|
||||
use Ulmus\Ldap\Entity\Field\{ Datetime, LdapDatetime };
|
||||
|
||||
/**
|
||||
* @ObjectClass('user')
|
||||
@@ -81,6 +81,11 @@ class User
|
||||
*/
|
||||
public string $title;
|
||||
|
||||
/**
|
||||
* @Field('readonly' => true)
|
||||
*/
|
||||
public ? array $memberOf;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
@@ -106,6 +111,61 @@ class User
|
||||
*/
|
||||
public string $extensionAttribute4;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute5;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute6;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute7;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute8;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute9;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute10;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute11;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute12;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute13;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute14;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public string $extensionAttribute15;
|
||||
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
@@ -124,20 +184,38 @@ class User
|
||||
/**
|
||||
* @Field
|
||||
*/
|
||||
public Datetime $lastLogonDate;
|
||||
public string $scriptPath;
|
||||
|
||||
/**
|
||||
* #Field('name' => 'createTimeStamp')
|
||||
* @Field
|
||||
*/
|
||||
# public Datetime $createdAt;
|
||||
public string $sid;
|
||||
|
||||
/**
|
||||
* #Field('name' => 'modifyTimeStamp')
|
||||
* @Field('name' => "lastLogon", 'readonly' => true)
|
||||
*/
|
||||
# public Datetime $updatedAt;
|
||||
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;
|
||||
return implode(' ', array_filter([ $this->firstname ?? "", $this->lastname ?? "" ])) ?: ( $this->displayName ?? "" );
|
||||
}
|
||||
|
||||
public function memberOfGroup() : array
|
||||
{
|
||||
$arr = array_map(fn($e) => explode('=', explode(',', $e)[0])[1], $this->memberOf);
|
||||
usort($arr, 'strcasecmp');
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user