Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Zend_Ldap_Dn Class Reference

Public Member Functions

 getRdn ($caseFold=null)
 Gets the RDN of the current DN.
 
 getRdnString ($caseFold=null)
 Gets the RDN of the current DN as a string.
 
 getParentDn ($levelUp=1)
 Get the parent DN $levelUp levels up the tree.
 
 get ($index, $length=1, $caseFold=null)
 Get a DN part.
 
 set ($index, array $value)
 Set a DN part.
 
 remove ($index, $length=1)
 Remove a DN part.
 
 append (array $value)
 Append a DN part.
 
 prepend (array $value)
 Prepend a DN part.
 
 insert ($index, array $value)
 Insert a DN part.
 
 setCaseFold ($caseFold)
 Sets the case fold.
 
 toString ($caseFold=null)
 Return DN as a string.
 
 toArray ($caseFold=null)
 Return DN as an array.
 
 __toString ()
 Cast to string representation {.
 
 offsetExists ($offset)
 Required by the ArrayAccess implementation.
 
 offsetGet ($offset)
 Proxy to {.
 
 offsetSet ($offset, $value)
 Proxy to {.
 
 offsetUnset ($offset)
 Proxy to {.
 

Static Public Member Functions

static factory ($dn, $caseFold=null)
 Creates a DN from an array or a string.
 
static fromString ($dn, $caseFold=null)
 Creates a DN from a string.
 
static fromArray (array $dn, $caseFold=null)
 Creates a DN from an array.
 
static setDefaultCaseFold ($caseFold)
 Sets the default case fold.
 
static escapeValue ($values=array())
 Escapes a DN value according to RFC 2253.
 
static unescapeValue ($values=array())
 Undoes the conversion done by escapeValue().
 
static explodeDn ($dn, array &$keys=null, array &$vals=null, $caseFold=self::ATTR_CASEFOLD_NONE)
 Creates an array containing all parts of the given DN.
 
static checkDn ($dn, array &$keys=null, array &$vals=null, $caseFold=self::ATTR_CASEFOLD_NONE)
 
static implodeRdn (array $part, $caseFold=null)
 Returns a DN part in the form $attribute = $value.
 
static implodeDn (array $dnArray, $caseFold=null, $separator= ',')
 Implodes an array in the form delivered by explodeDn() to a DN string.
 
static isChildOf ($childDn, $parentDn)
 Checks if given $childDn is beneath $parentDn subtree.
 

Public Attributes

const ATTR_CASEFOLD_NONE = 'none'
 
const ATTR_CASEFOLD_UPPER = 'upper'
 
const ATTR_CASEFOLD_LOWER = 'lower'
 

Protected Member Functions

 __construct (array $dn, $caseFold)
 Constructor.
 
 _assertIndex ($index)
 Assert index is correct and usable.
 

Static Protected Member Functions

static _assertRdn (array $value)
 Assert if value is in a correct RDN format.
 
static _caseFoldRdn (array $part, $caseFold)
 Do a case folding on a RDN.
 
static _caseFoldDn (array $dn, $caseFold)
 Do a case folding on a DN ort part of it.
 
static _sanitizeCaseFold ($caseFold, $default)
 Sanitizes the case fold.
 

Protected Attributes

 $_caseFold
 
 $_dn
 

Static Protected Attributes

static $_defaultCaseFold = self::ATTR_CASEFOLD_NONE
 

Constructor & Destructor Documentation

__construct ( array  $dn,
  $caseFold 
)
protected

Constructor.

Parameters
array$dn
string | null$caseFold

Member Function Documentation

__toString ( )

Cast to string representation {.

See Also
toString()}
Returns
string
_assertIndex (   $index)
protected

Assert index is correct and usable.

Parameters
mixed$index
Returns
boolean
Exceptions
Zend_Ldap_Exception

Zend_Ldap_Exception

Zend_Ldap_Exception

static _assertRdn ( array  $value)
staticprotected

Assert if value is in a correct RDN format.

Parameters
array$value
Returns
boolean
Exceptions
Zend_Ldap_Exception

Zend_Ldap_Exception

Zend_Ldap_Exception

static _caseFoldDn ( array  $dn,
  $caseFold 
)
staticprotected

Do a case folding on a DN ort part of it.

Parameters
array$dn
string$caseFold
Returns
array
static _caseFoldRdn ( array  $part,
  $caseFold 
)
staticprotected

Do a case folding on a RDN.

Parameters
array$part
string$caseFold
Returns
array
static _sanitizeCaseFold (   $caseFold,
  $default 
)
staticprotected

Sanitizes the case fold.

Parameters
string$caseFold
Returns
string
append ( array  $value)

Append a DN part.

Parameters
array$value
Returns
Zend_Ldap_Dn Provides a fluent interface
static checkDn (   $dn,
array &  $keys = null,
array &  $vals = null,
  $caseFold = self::ATTR_CASEFOLD_NONE 
)
static
Parameters
string$dnThe DN to parse
array$keysAn optional array to receive DN keys (e.g. CN, OU, DC, ...)
array$valsAn optional array to receive DN values
string$caseFold
Returns
boolean True if the DN was successfully parsed or false if the string is not a valid DN.
static escapeValue (   $values = array())
static

Escapes a DN value according to RFC 2253.

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 . Finally all leading and trailing spaces are converted to sequences of \20.

See Also
Net_LDAP2_Util::escape_dn_value() from Benedikt Hallinger beni@.nosp@m.php..nosp@m.net Benedikt Hallinger beni@.nosp@m.php..nosp@m.net string|array $values An array containing the DN values that should be escaped array The array $values, but escaped
See Also
Zend_Ldap_Converter
static explodeDn (   $dn,
array &  $keys = null,
array &  $vals = null,
  $caseFold = self::ATTR_CASEFOLD_NONE 
)
static

Creates an array containing all parts of the given DN.

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
string$dn
array$keysAn optional array to receive DN keys (e.g. CN, OU, DC, ...)
array$valsAn optional array to receive DN values
string$caseFold
Returns
array
Exceptions
Zend_Ldap_Exception

Zend_Ldap_Exception

static factory (   $dn,
  $caseFold = null 
)
static

Creates a DN from an array or a string.

Parameters
string | array$dn
string | null$caseFold
Returns
Zend_Ldap_Dn
Exceptions
Zend_Ldap_Exception

Zend_Ldap_Exception

static fromArray ( array  $dn,
  $caseFold = null 
)
static

Creates a DN from an array.

Parameters
array$dn
string | null$caseFold
Returns
Zend_Ldap_Dn
Exceptions
Zend_Ldap_Exception
static fromString (   $dn,
  $caseFold = null 
)
static

Creates a DN from a string.

Parameters
string$dn
string | null$caseFold
Returns
Zend_Ldap_Dn
Exceptions
Zend_Ldap_Exception
get (   $index,
  $length = 1,
  $caseFold = null 
)

Get a DN part.

Parameters
int$index
int$length
string$caseFold
Returns
array
Exceptions
Zend_Ldap_Exceptionif index is illegal
getParentDn (   $levelUp = 1)

Get the parent DN $levelUp levels up the tree.

Parameters
int$levelUp
Returns
Zend_Ldap_Dn

Zend_Ldap_Exception

getRdn (   $caseFold = null)

Gets the RDN of the current DN.

Parameters
string$caseFold
Returns
array
Exceptions
Zend_Ldap_Exceptionif DN has no RDN (empty array)
getRdnString (   $caseFold = null)

Gets the RDN of the current DN as a string.

Parameters
string$caseFold
Returns
string
Exceptions
Zend_Ldap_Exceptionif DN has no RDN (empty array)
static implodeDn ( array  $dnArray,
  $caseFold = null,
  $separator = ',' 
)
static

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

$dnArray must be of type array( array("cn" => "name1", "uid" => "user"), array("cn" => "name2"), array("dc" => "example"), array("dc" => "org") )

Parameters
array$dnArray
string$caseFold
string$separator
Returns
string
Exceptions
Zend_Ldap_Exception
static implodeRdn ( array  $part,
  $caseFold = null 
)
static

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

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

Parameters
array$attribute
string$caseFold
Returns
string
Exceptions
Zend_Ldap_Exception
insert (   $index,
array  $value 
)

Insert a DN part.

Parameters
int$index
array$value
Returns
Zend_Ldap_Dn Provides a fluent interface
Exceptions
Zend_Ldap_Exceptionif index is illegal
static isChildOf (   $childDn,
  $parentDn 
)
static

Checks if given $childDn is beneath $parentDn subtree.

Parameters
string | Zend_Ldap_Dn$childDn
string | Zend_Ldap_Dn$parentDn
Returns
boolean
offsetExists (   $offset)

Required by the ArrayAccess implementation.

Parameters
int$offset
Returns
boolean
offsetGet (   $offset)

Proxy to {.

See Also
get()} Required by the ArrayAccess implementation
Parameters
int$offset
Returns
array
offsetSet (   $offset,
  $value 
)

Proxy to {.

See Also
set()} Required by the ArrayAccess implementation
Parameters
int$offset
array$value
offsetUnset (   $offset)

Proxy to {.

See Also
remove()} Required by the ArrayAccess implementation
Parameters
int$offset
prepend ( array  $value)

Prepend a DN part.

Parameters
array$value
Returns
Zend_Ldap_Dn Provides a fluent interface
remove (   $index,
  $length = 1 
)

Remove a DN part.

Parameters
int$index
int$length
Returns
Zend_Ldap_Dn Provides a fluent interface
Exceptions
Zend_Ldap_Exceptionif index is illegal
set (   $index,
array  $value 
)

Set a DN part.

Parameters
int$index
array$value
Returns
Zend_Ldap_Dn Provides a fluent interface
Exceptions
Zend_Ldap_Exceptionif index is illegal
setCaseFold (   $caseFold)

Sets the case fold.

Parameters
string | null$caseFold
static setDefaultCaseFold (   $caseFold)
static

Sets the default case fold.

Parameters
string$caseFold
toArray (   $caseFold = null)

Return DN as an array.

Parameters
string$caseFold
Returns
array
toString (   $caseFold = null)

Return DN as a string.

Parameters
string$caseFold
Returns
string
Exceptions
Zend_Ldap_Exception
static unescapeValue (   $values = array())
static

Undoes the conversion done by escapeValue().

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

See Also
Net_LDAP2_Util::escape_dn_value() from Benedikt Hallinger beni@.nosp@m.php..nosp@m.net Benedikt Hallinger beni@.nosp@m.php..nosp@m.net string|array $values Array of DN Values array Same as $values, but unescaped
See Also
Zend_Ldap_Converter

Member Data Documentation

$_caseFold
protected
$_defaultCaseFold = self::ATTR_CASEFOLD_NONE
staticprotected
$_dn
protected
const ATTR_CASEFOLD_LOWER = 'lower'
const ATTR_CASEFOLD_NONE = 'none'
const ATTR_CASEFOLD_UPPER = 'upper'