Zend\Ldap\Dn provides an API for DN manipulation

category Zend
package Zend_Ldap

 Methods

Cast to string representation {@see toString()}

__toString() : string

Returns

string

Append a DN part

append(array $value) : \Zend\Ldap\Dn

Parameters

$value

array

Returns

\Zend\Ldap\DnProvides a fluent interface

checkDn()

checkDn(string $dn, array $keys, array $vals, string $caseFold) : bool

Parameters

$dn

string

The DN to parse

$keys

array

An optional array to receive DN keys (e.g. CN, OU, DC, ...)

$vals

array

An optional array to receive DN values

$caseFold

string

Returns

boolTrue if the DN was successfully parsed or false if the string is not a valid DN.

Escapes a DN value according to RFC 2253

escapeValue(string | array $values) : array

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 preceeded 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.

see \Zend\Ldap\Net_LDAP2_Util::escape_dn_value()
link http://pear.php.net/package/Net_LDAP2
author Benedikt Hallinger

Parameters

$values

stringarray

An array containing the DN values that should be escaped

Returns

arrayThe array $values, but escaped

Creates an array containing all parts of the given DN.

explodeDn(string $dn, array $keys, array $vals, string $caseFold) : array

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

An optional array to receive DN keys (e.g. CN, OU, DC, ...)

$vals

array

An optional array to receive DN values

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

array

Creates a DN from an array or a string

factory(string | array $dn, string | null $caseFold) : \Zend\Ldap\Dn

Parameters

$dn

stringarray

$caseFold

stringnull

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

Creates a DN from an array

fromArray(array $dn, string | null $caseFold) : \Zend\Ldap\Dn

Parameters

$dn

array

$caseFold

stringnull

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

Creates a DN from a string

fromString(string $dn, string | null $caseFold) : \Zend\Ldap\Dn

Parameters

$dn

string

$caseFold

stringnull

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

Get a DN part

get(int $index, int $length, string $caseFold) : array

Parameters

$index

int

$length

int

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException if index is illegal

Returns

array

Get the parent DN $levelUp levels up the tree

getParentDn(int $levelUp) : \Zend\Ldap\Dn

Parameters

$levelUp

int

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

Gets the RDN of the current DN

getRdn(string $caseFold) : array

Parameters

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException if DN has no RDN (empty array)

Returns

array

Gets the RDN of the current DN as a string

getRdnString(string $caseFold) : string

Parameters

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException if DN has no RDN (empty array)

Returns

string

Implodes an array in the form delivered by {@link explodeDn()} to a DN string.

implodeDn(array $dnArray, string $caseFold, 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

$caseFold

string

$separator

string

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

string

Returns a DN part in the form $attribute = $value

implodeRdn(array $part, string $caseFold) : string

This method supports the creation of multi-valued RDNs $part must contain an even number of elements.

Parameters

$part

array

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

string

Insert a DN part

insert(int $index, array $value) : \Zend\Ldap\Dn

Parameters

$index

int

$value

array

Exceptions

\Zend\Ldap\Exception\LdapException if index is illegal

Returns

\Zend\Ldap\DnProvides a fluent interface

Checks if given $childDn is beneath $parentDn subtree.

isChildOf(string | \Zend\Ldap\Dn $childDn, string | \Zend\Ldap\Dn $parentDn) : bool

Parameters

$childDn

string\Zend\Ldap\Dn

$parentDn

string\Zend\Ldap\Dn

Returns

bool

Required by the ArrayAccess implementation

offsetExists(int $offset) : bool

Parameters

$offset

int

Returns

bool

Proxy to {@see get()} Required by the ArrayAccess implementation

offsetGet(int $offset) : array

Parameters

$offset

int

Returns

array

Proxy to {@see set()} Required by the ArrayAccess implementation

offsetSet(int $offset, array $value) 

Parameters

$offset

int

$value

array

Proxy to {@see remove()} Required by the ArrayAccess implementation

offsetUnset(int $offset) 

Parameters

$offset

int

Prepend a DN part

prepend(array $value) : \Zend\Ldap\Dn

Parameters

$value

array

Returns

\Zend\Ldap\DnProvides a fluent interface

Remove a DN part

remove(int $index, int $length) : \Zend\Ldap\Dn

Parameters

$index

int

$length

int

Exceptions

\Zend\Ldap\Exception\LdapException if index is illegal

Returns

\Zend\Ldap\DnProvides a fluent interface

Set a DN part

set(int $index, array $value) : \Zend\Ldap\Dn

Parameters

$index

int

$value

array

Exceptions

\Zend\Ldap\Exception\LdapException if index is illegal

Returns

\Zend\Ldap\DnProvides a fluent interface

Sets the case fold

setCaseFold(string | null $caseFold) 

Parameters

$caseFold

stringnull

Sets the default case fold

setDefaultCaseFold(string $caseFold) 

Parameters

$caseFold

string

Return DN as an array

toArray(string $caseFold) : array

Parameters

$caseFold

string

Returns

array

Return DN as a string

toString(string $caseFold) : string

Parameters

$caseFold

string

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

string

Undoes the conversion done by {@link escapeValue()}.

unescapeValue(string | array $values) : array

Any escape sequence starting with a baskslash - hexpair or special character - will be transformed back to the corresponding character.

see \Zend\Ldap\Net_LDAP2_Util::escape_dn_value()
link http://pear.php.net/package/Net_LDAP2
author Benedikt Hallinger

Parameters

$values

stringarray

Array of DN Values

Returns

arraySame as $values, but unescaped

Constructor

__construct(array $dn, string | null $caseFold) 

Parameters

$dn

array

$caseFold

stringnull

Assert index is correct and usable

assertIndex(mixed $index) : bool

Parameters

$index

mixed

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

bool

Assert if value is in a correct RDN format

assertRdn(array $value) : bool

Parameters

$value

array

Exceptions

\Zend\Ldap\Exception\LdapException

Returns

bool

Do a case folding on a DN ort part of it

caseFoldDn(array $dn, string $caseFold) : array

Parameters

$dn

array

$caseFold

string

Returns

array

Do a case folding on a RDN

caseFoldRdn(array $part, string $caseFold) : array

Parameters

$part

array

$caseFold

string

Returns

array

Sanitizes the case fold

sanitizeCaseFold(string $caseFold, string $default) : string

Parameters

$caseFold

string

$default

string

Returns

string

 Properties

 

The case fold used for this instance

$caseFold : string

 

The default case fold to use

$defaultCaseFold : string

 

The DN data

$dn : array

 Constants

 

ATTR_CASEFOLD_LOWER

ATTR_CASEFOLD_LOWER 

 

ATTR_CASEFOLD_NONE

ATTR_CASEFOLD_NONE 

 

ATTR_CASEFOLD_UPPER

ATTR_CASEFOLD_UPPER