Handle RFC3866 Language Tags

This commit is contained in:
2023-03-27 16:19:37 +11:00
parent 61202d3617
commit f043c74ae6
4 changed files with 69 additions and 7 deletions

View File

@@ -33,12 +33,16 @@ class Attribute
// Is this attribute the RDN?
protected bool $is_rdn = FALSE;
// Objectclasses that require this attribute
protected Collection $required_by;
// MIN/MAX number of values
protected int $min_values_count = 0;
protected int $max_values_count = 0;
// RFC3866 Language Tags
protected Collection $lang_tags;
/*
# Has the attribute been modified
protected $modified = false;
@@ -94,6 +98,7 @@ class Attribute
{
$this->name = $name;
$this->values = collect($values);
$this->lang_tags = collect();
// No need to load our schema for internal attributes
if (! $this->is_internal)
@@ -183,6 +188,10 @@ class Attribute
if ($this->required_by->count())
$result->put(__('required'),sprintf('%s: %s',__('Required Attribute by ObjectClass(es)'),$this->required_by->join(',')));
// This attribute has language tags
if ($this->lang_tags->count())
$result->put(__('language tags'),sprintf('%s: %d',__('This Attribute has Language Tags'),$this->lang_tags->count()));
return $result->toArray();
}
@@ -199,6 +208,18 @@ class Attribute
: collect());
}
/**
* If this attribute has RFC3866 Language Tags, this will enable those values to be captured
*
* @param string $tag
* @param array $value
* @return void
*/
public function setLangTag(string $tag,array $value): void
{
$this->lang_tags->put($tag,$value);
}
public function setRDN(): void
{
$this->is_rdn = TRUE;

View File

@@ -266,6 +266,18 @@ class Server
return in_array($attr_name,config('pla.force_may',[]));
}
/**
* Does this server support RFC3666 language tags
* OID: 1.3.6.1.4.1.4203.1.5.4
*
* @return bool
* @throws ObjectNotFoundException
*/
public function isLanguageTags(): bool
{
return in_array('1.3.6.1.4.1.4203.1.5.4',$this->rootDSE()->supportedfeatures);
}
/**
* Return the server's schema
*
@@ -513,6 +525,13 @@ class Server
return is_null($key) ? $result : $result->get($key);
}
/**
* Given an OID, return the ldapsyntax for the OID
*
* @param string $oid
* @return LDAPSyntax|null
* @throws InvalidUsage
*/
public function schemaSyntaxName(string $oid): ?LDAPSyntax
{
return $this->schema('ldapsyntaxes',$oid);