Dn
in package
implements
ArrayAccess
Laminas\Ldap\Dn provides an API for DN manipulation
Tags
Table of Contents
Interfaces
- ArrayAccess
Constants
- ATTR_CASEFOLD_LOWER = 'lower'
- ATTR_CASEFOLD_NONE = 'none'
- ATTR_CASEFOLD_UPPER = 'upper'
Properties
- $caseFold : string
- The case fold used for this instance
- $defaultCaseFold : string
- The default case fold to use
- $dn : array<string|int, mixed>
- The DN data
Methods
- __toString() : string
- Cast to string representation {@see toString()}
- append() : Dn
- Append a DN part
- checkDn() : bool
- escapeValue() : array<string|int, mixed>
- Escapes a DN value according to RFC 2253
- explodeDn() : array<string|int, mixed>
- Creates an array containing all parts of the given DN.
- factory() : Dn
- Creates a DN from an array or a string
- fromArray() : Dn
- Creates a DN from an array
- fromString() : Dn
- Creates a DN from a string
- get() : array<string|int, mixed>
- Get a DN part
- getParentDn() : Dn
- Get the parent DN $levelUp levels up the tree
- getRdn() : array<string|int, mixed>
- Gets the RDN of the current DN
- getRdnString() : string
- Gets the RDN of the current DN as a string
- implodeDn() : string
- Implodes an array in the form delivered by {@link explodeDn()} to a DN string.
- implodeRdn() : string
- Returns a DN part in the form $attribute = $value
- insert() : Dn
- Insert a DN part
- isChildOf() : bool
- Checks if given $childDn is beneath $parentDn subtree.
- offsetExists() : mixed
- offsetGet() : mixed
- offsetSet() : mixed
- offsetUnset() : mixed
- prepend() : Dn
- Prepend a DN part
- remove() : Dn
- Remove a DN part
- set() : Dn
- Set a DN part
- setCaseFold() : mixed
- Sets the case fold
- setDefaultCaseFold() : mixed
- Sets the default case fold
- toArray() : array<string|int, mixed>
- Return DN as an array
- toString() : string
- Return DN as a string
- unescapeValue() : mixed
- Undoes the conversion done by {@link escapeValue()}.
- __construct() : mixed
- Constructor
- assertIndex() : bool
- Assert index is correct and usable
- assertRdn() : void
- Assert if value is in a correct RDN format
- caseFoldDn() : array<string|int, mixed>
- Do a case folding on a DN ort part of it
- caseFoldRdn() : array<string|int, mixed>
- Do a case folding on a RDN
- sanitizeCaseFold() : string
- Sanitizes the case fold
Constants
ATTR_CASEFOLD_LOWER
public
mixed
ATTR_CASEFOLD_LOWER
= 'lower'
ATTR_CASEFOLD_NONE
public
mixed
ATTR_CASEFOLD_NONE
= 'none'
ATTR_CASEFOLD_UPPER
public
mixed
ATTR_CASEFOLD_UPPER
= 'upper'
Properties
$caseFold
The case fold used for this instance
protected
string
$caseFold
$defaultCaseFold
The default case fold to use
protected
static string
$defaultCaseFold
= self::ATTR_CASEFOLD_NONE
$dn
The DN data
protected
array<string|int, mixed>
$dn
Methods
__toString()
Cast to string representation {@see toString()}
public
__toString() : string
Return values
stringappend()
Append a DN part
public
append(array<string|int, mixed> $value) : Dn
Parameters
- $value : array<string|int, mixed>
Return values
Dn —Provides a fluent interface
checkDn()
public
static checkDn(string $dn[, array<string|int, mixed> &$keys = null ][, array<string|int, mixed> &$vals = null ][, string $caseFold = self::ATTR_CASEFOLD_NONE ]) : bool
Parameters
- $dn : string
-
The DN to parse
- $keys : array<string|int, mixed> = null
-
An optional array to receive DN keys (e.g. CN, OU, DC, ...)
- $vals : array<string|int, mixed> = null
-
An optional array to receive DN values
- $caseFold : string = self::ATTR_CASEFOLD_NONE
Return values
bool —True if the DN was successfully parsed or false if the string is not a valid DN.
escapeValue()
Escapes a DN value according to RFC 2253
public
static escapeValue([string|array<string|int, mixed> $values = [] ]) : array<string|int, mixed>
Escapes the given VALUES according to RFC 2253 so that they can be safely used in LDAP DNs. The characters ",", "+", """, "", "<", ">", ";", "#", " = " with a special meaning in RFC 2252 are preceded by ba backslash. Control characters with an ASCII code < 32 are represented as \hexpair. Finally all leading and trailing spaces are converted to sequences of \20.
Parameters
- $values : string|array<string|int, mixed> = []
-
An array containing the DN values that should be escaped
Tags
Return values
array<string|int, mixed> —The array $values, but escaped
explodeDn()
Creates an array containing all parts of the given DN.
public
static explodeDn(string $dn[, array<string|int, mixed> &$keys = null ][, array<string|int, mixed> &$vals = null ][, string $caseFold = self::ATTR_CASEFOLD_NONE ]) : array<string|int, mixed>
Array will be of type array( array("cn" => "name1", "uid" => "user"), array("cn" => "name2"), array("dc" => "example"), array("dc" => "org") ) for a DN of cn=name1+uid=user,cn=name2,dc=example,dc=org.
Parameters
- $dn : string
- $keys : array<string|int, mixed> = null
-
An optional array to receive DN keys (e.g. CN, OU, DC, ...)
- $vals : array<string|int, mixed> = null
-
An optional array to receive DN values
- $caseFold : string = self::ATTR_CASEFOLD_NONE
Tags
Return values
array<string|int, mixed>factory()
Creates a DN from an array or a string
public
static factory(string|array<string|int, mixed> $dn[, string|null $caseFold = null ]) : Dn
Parameters
- $dn : string|array<string|int, mixed>
- $caseFold : string|null = null
Tags
Return values
DnfromArray()
Creates a DN from an array
public
static fromArray(array<string|int, mixed> $dn[, string|null $caseFold = null ]) : Dn
Parameters
- $dn : array<string|int, mixed>
- $caseFold : string|null = null
Tags
Return values
DnfromString()
Creates a DN from a string
public
static fromString(string $dn[, string|null $caseFold = null ]) : Dn
Parameters
- $dn : string
- $caseFold : string|null = null
Tags
Return values
Dnget()
Get a DN part
public
get(int $index[, int $length = 1 ][, string $caseFold = null ]) : array<string|int, mixed>
Parameters
- $index : int
- $length : int = 1
- $caseFold : string = null
Tags
Return values
array<string|int, mixed>getParentDn()
Get the parent DN $levelUp levels up the tree
public
getParentDn([int $levelUp = 1 ]) : Dn
Parameters
- $levelUp : int = 1
Tags
Return values
DngetRdn()
Gets the RDN of the current DN
public
getRdn([string $caseFold = null ]) : array<string|int, mixed>
Parameters
- $caseFold : string = null
Tags
Return values
array<string|int, mixed>getRdnString()
Gets the RDN of the current DN as a string
public
getRdnString([string $caseFold = null ]) : string
Parameters
- $caseFold : string = null
Tags
Return values
stringimplodeDn()
Implodes an array in the form delivered by {@link explodeDn()} to a DN string.
public
static implodeDn(array<string|int, mixed> $dnArray[, string $caseFold = null ][, string $separator = ',' ]) : string
$dnArray must be of type array( array("cn" => "name1", "uid" => "user"), array("cn" => "name2"), array("dc" => "example"), array("dc" => "org") )
Parameters
- $dnArray : array<string|int, mixed>
- $caseFold : string = null
- $separator : string = ','
Tags
Return values
stringimplodeRdn()
Returns a DN part in the form $attribute = $value
public
static implodeRdn(array<string|int, mixed> $part[, string $caseFold = null ]) : string
This method supports the creation of multi-valued RDNs $part must contain an even number of elements.
Parameters
- $part : array<string|int, mixed>
- $caseFold : string = null
Tags
Return values
stringinsert()
Insert a DN part
public
insert(int $index, array<string|int, mixed> $value) : Dn
Parameters
- $index : int
- $value : array<string|int, mixed>
Tags
Return values
Dn —Provides a fluent interface
isChildOf()
Checks if given $childDn is beneath $parentDn subtree.
public
static isChildOf(string|Dn $childDn, string|Dn $parentDn) : bool
Parameters
Return values
booloffsetExists()
public
offsetExists(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
offsetGet()
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
offsetSet()
public
offsetSet(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Tags
Attributes
offsetUnset()
public
offsetUnset(mixed $offset) : mixed
Parameters
- $offset : mixed
Tags
Attributes
prepend()
Prepend a DN part
public
prepend(array<string|int, mixed> $value) : Dn
Parameters
- $value : array<string|int, mixed>
Return values
Dn —Provides a fluent interface
remove()
Remove a DN part
public
remove(int $index[, int $length = 1 ]) : Dn
Parameters
- $index : int
- $length : int = 1
Tags
Return values
Dn —Provides a fluent interface
set()
Set a DN part
public
set(int $index, array<string|int, mixed> $value) : Dn
Parameters
- $index : int
- $value : array<string|int, mixed>
Tags
Return values
Dn —Provides a fluent interface
setCaseFold()
Sets the case fold
public
setCaseFold(string|null $caseFold) : mixed
Parameters
- $caseFold : string|null
setDefaultCaseFold()
Sets the default case fold
public
static setDefaultCaseFold(string $caseFold) : mixed
Parameters
- $caseFold : string
toArray()
Return DN as an array
public
toArray([string $caseFold = null ]) : array<string|int, mixed>
Parameters
- $caseFold : string = null
Return values
array<string|int, mixed>toString()
Return DN as a string
public
toString([string $caseFold = null ]) : string
Parameters
- $caseFold : string = null
Tags
Return values
stringunescapeValue()
Undoes the conversion done by {@link escapeValue()}.
public
static unescapeValue([TInput $values = [] ]) : mixed
Any escape sequence starting with a baskslash - hexpair or special character - will be transformed back to the corresponding character.
Parameters
- $values : TInput = []
-
Array of DN Values
Tags
__construct()
Constructor
protected
__construct(array<string|int, mixed> $dn, string|null $caseFold) : mixed
Parameters
- $dn : array<string|int, mixed>
- $caseFold : string|null
assertIndex()
Assert index is correct and usable
protected
assertIndex(mixed $index) : bool
Parameters
- $index : mixed
Tags
Return values
boolassertRdn()
Assert if value is in a correct RDN format
protected
static assertRdn(array<string|int, mixed> $value) : void
Parameters
- $value : array<string|int, mixed>
Tags
caseFoldDn()
Do a case folding on a DN ort part of it
protected
static caseFoldDn(array<string|int, mixed> $dn, string $caseFold) : array<string|int, mixed>
Parameters
- $dn : array<string|int, mixed>
- $caseFold : string
Return values
array<string|int, mixed>caseFoldRdn()
Do a case folding on a RDN
protected
static caseFoldRdn(array<string|int, mixed> $part, string $caseFold) : array<string|int, mixed>
Parameters
- $part : array<string|int, mixed>
- $caseFold : string
Return values
array<string|int, mixed>sanitizeCaseFold()
Sanitizes the case fold
protected
static sanitizeCaseFold(string $caseFold, string $default) : string
Parameters
- $caseFold : string
- $default : string