HumHub Documentation (unofficial)

Dn
in package
implements ArrayAccess

Laminas\Ldap\Dn provides an API for DN manipulation

Tags
template-implements

ArrayAccess<int, array>

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
string

append()

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
link
http://pear.php.net/package/Net_LDAP2
see
Net_LDAP2_Util::escape_dn_value()

from Benedikt Hallinger beni@php.net

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
throws
LdapException
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
throws
LdapException
Return values
Dn

fromArray()

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
throws
LdapException
Return values
Dn

fromString()

Creates a DN from a string

public static fromString(string $dn[, string|null $caseFold = null ]) : Dn
Parameters
$dn : string
$caseFold : string|null = null
Tags
throws
LdapException
Return values
Dn

get()

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
throws
LdapException

If index is illegal.

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
throws
LdapException
Return values
Dn

getRdn()

Gets the RDN of the current DN

public getRdn([string $caseFold = null ]) : array<string|int, mixed>
Parameters
$caseFold : string = null
Tags
throws
LdapException

If DN has no RDN (empty array).

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
throws
LdapException

If DN has no RDN (empty array).

Return values
string

implodeDn()

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
throws
LdapException
Return values
string

implodeRdn()

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
throws
LdapException
Return values
string

insert()

Insert a DN part

public insert(int $index, array<string|int, mixed> $value) : Dn
Parameters
$index : int
$value : array<string|int, mixed>
Tags
throws
LdapException

If index is illegal.

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
$childDn : string|Dn
$parentDn : string|Dn
Return values
bool

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
inheritDoc
Attributes
#[ReturnTypeWillChange]

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
inheritDoc
Attributes
#[ReturnTypeWillChange]

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Tags
inheritDoc
Attributes
#[ReturnTypeWillChange]

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Tags
inheritDoc
Attributes
#[ReturnTypeWillChange]

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
throws
LdapException

If index is illegal.

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
throws
LdapException

If index is illegal.

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
throws
LdapException
Return values
string

unescapeValue()

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
link
http://pear.php.net/package/Net_LDAP2
see
Net_LDAP2_Util::escape_dn_value()

from Benedikt Hallinger beni@php.net

template

TInput of string|array

__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
throws
LdapException
Return values
bool

assertRdn()

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
throws
LdapException

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
Return values
string

        
On this page

Search results