Work out which attributes are available to a DN
This commit is contained in:
parent
9d1d969113
commit
6d900d0964
@ -120,6 +120,8 @@ class Attribute
|
|||||||
public function __get(string $key): mixed
|
public function __get(string $key): mixed
|
||||||
{
|
{
|
||||||
return match ($key) {
|
return match ($key) {
|
||||||
|
// List all the attributes
|
||||||
|
'attributes' => $this->attributes(),
|
||||||
// Can this attribute have more values
|
// Can this attribute have more values
|
||||||
'can_addvalues' => $this->schema && (! $this->schema->is_single_value) && ((! $this->max_values_count) || ($this->values->count() < $this->max_values_count)),
|
'can_addvalues' => $this->schema && (! $this->schema->is_single_value) && ((! $this->max_values_count) || ($this->values->count() < $this->max_values_count)),
|
||||||
// Schema attribute description
|
// Schema attribute description
|
||||||
@ -143,6 +145,11 @@ class Attribute
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return $this->__get('name');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the hints about this attribute, ie: RDN, Required, etc
|
* Return the hints about this attribute, ie: RDN, Required, etc
|
||||||
*
|
*
|
||||||
|
@ -46,6 +46,16 @@ abstract class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __isset(string $key): bool
|
||||||
|
{
|
||||||
|
return isset($this->{$key});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
* @deprecated replace with $class->description
|
* @deprecated replace with $class->description
|
||||||
|
@ -200,6 +200,9 @@ final class ObjectClass extends Base {
|
|||||||
public function __get(string $key): mixed
|
public function __get(string $key): mixed
|
||||||
{
|
{
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
|
case 'attributes':
|
||||||
|
return $this->getAllAttrs();
|
||||||
|
|
||||||
case 'sup':
|
case 'sup':
|
||||||
return $this->sup_classes;
|
return $this->sup_classes;
|
||||||
|
|
||||||
@ -216,6 +219,16 @@ final class ObjectClass extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of attributes that this objectClass provides
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAllAttrs(): Collection
|
||||||
|
{
|
||||||
|
return $this->getMustAttrs()->merge($this->getMayAttrs());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an objectClass to the list of objectClasses that inherit
|
* Adds an objectClass to the list of objectClasses that inherit
|
||||||
* from this objectClass.
|
* from this objectClass.
|
||||||
@ -229,6 +242,17 @@ final class ObjectClass extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the array of objectClass names which inherit from this objectClass.
|
||||||
|
*
|
||||||
|
* @return Collection Names of objectClasses which inherit from this objectClass.
|
||||||
|
* @deprecated use $this->child_objectclasses
|
||||||
|
*/
|
||||||
|
public function getChildObjectClasses(): Collection
|
||||||
|
{
|
||||||
|
return $this->child_objectclasses;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behaves identically to addMustAttrs, but it operates on the MAY
|
* Behaves identically to addMustAttrs, but it operates on the MAY
|
||||||
* attributes of this objectClass.
|
* attributes of this objectClass.
|
||||||
@ -397,6 +421,27 @@ final class ObjectClass extends Base {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the objectClass names from which this objectClass inherits.
|
||||||
|
*
|
||||||
|
* @return Collection An array of objectClass names (strings)
|
||||||
|
* @deprecated use $this->sup_classes;
|
||||||
|
*/
|
||||||
|
public function getSupClasses(): Collection
|
||||||
|
{
|
||||||
|
return $this->sup_classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of this objectClass: STRUCTURAL, ABSTRACT, or AUXILIARY.
|
||||||
|
*
|
||||||
|
* @deprecated use $this->type_name
|
||||||
|
*/
|
||||||
|
public function getType()
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if an array is listed in the may_force attrs
|
* Determine if an array is listed in the may_force attrs
|
||||||
*/
|
*/
|
||||||
@ -492,35 +537,4 @@ final class ObjectClass extends Base {
|
|||||||
|
|
||||||
return $i;
|
return $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the array of objectClass names which inherit from this objectClass.
|
|
||||||
*
|
|
||||||
* @return Collection Names of objectClasses which inherit from this objectClass.
|
|
||||||
* @deprecated use $this->child_objectclasses
|
|
||||||
*/
|
|
||||||
public function getChildObjectClasses(): Collection
|
|
||||||
{
|
|
||||||
return $this->child_objectclasses;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the objectClass names from which this objectClass inherits.
|
|
||||||
*
|
|
||||||
* @return array An array of objectClass names (strings)
|
|
||||||
* @deprecated use $this->sup_classes;
|
|
||||||
*/
|
|
||||||
public function getSupClasses() {
|
|
||||||
return $this->sup_classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the type of this objectClass: STRUCTURAL, ABSTRACT, or AUXILIARY.
|
|
||||||
*
|
|
||||||
* @deprecated use $this->type_name
|
|
||||||
*/
|
|
||||||
public function getType()
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -103,6 +103,21 @@ class Entry extends Model
|
|||||||
return Crypt::encryptString($this->getDn());
|
return Crypt::encryptString($this->getDn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of available attributes - as per the objectClass entry of the record
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAvailableAttributes(): Collection
|
||||||
|
{
|
||||||
|
$result = collect();
|
||||||
|
|
||||||
|
foreach ($this->objectclass as $oc)
|
||||||
|
$result = $result->merge(config('server')->schema('objectclasses',$oc)->attributes);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of LDAP internal attributes
|
* Return a list of LDAP internal attributes
|
||||||
*
|
*
|
||||||
@ -115,6 +130,16 @@ class Entry extends Model
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a list of attributes without any values
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getMissingAttributes(): Collection
|
||||||
|
{
|
||||||
|
return $this->getAvailableAttributes()->diff($this->getVisibleAttributes());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return this list of user attributes
|
* Return this list of user attributes
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user