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

Public Member Functions

 __sleep ()
 Serialization callback.
 
 __wakeup ()
 Deserialization callback.
 
 getLdap ()
 Gets the current LDAP connection.
 
 attachLdap (Zend_Ldap $ldap)
 Attach node to an LDAP connection.
 
 detachLdap ()
 Detach node from LDAP connection.
 
 isAttached ()
 Checks if the current node is attached to a LDAP server.
 
 isNew ()
 Tells if the node is consiedered as new (not present on the server)
 
 willBeDeleted ()
 Is this node going to be deleted once update() is called?
 
 delete ()
 Marks this node as to be deleted.
 
 willBeMoved ()
 Is this node going to be moved once update() is called?
 
 update (Zend_Ldap $ldap=null)
 Sends all pending changes to the LDAP server.
 
 getCurrentDn ()
 Gets the current DN of the current node as a Zend_Ldap_Dn.
 
 setDn ($newDn)
 Sets the new DN for this node.
 
 move ($newDn)
 {
 
 rename ($newDn)
 {
 
 setObjectClass ($value)
 Sets the objectClass.
 
 appendObjectClass ($value)
 Appends to the objectClass.
 
 toLdif (array $options=array())
 Returns a LDIF representation of the current node.
 
 getChangedData ()
 Gets changed node data.
 
 getChanges ()
 Returns all changes made.
 
 setAttribute ($name, $value)
 Sets a LDAP attribute.
 
 appendToAttribute ($name, $value)
 Appends to a LDAP attribute.
 
 setDateTimeAttribute ($name, $value, $utc=false)
 Sets a LDAP date/time attribute.
 
 appendToDateTimeAttribute ($name, $value, $utc=false)
 Appends to a LDAP date/time attribute.
 
 setPasswordAttribute ($password, $hashType=Zend_Ldap_Attribute::PASSWORD_HASH_MD5, $attribName= 'userPassword')
 Sets a LDAP password.
 
 deleteAttribute ($name)
 Deletes a LDAP attribute.
 
 removeDuplicatesFromAttribute ($attribName)
 Removes duplicate values from a LDAP attribute.
 
 removeFromAttribute ($attribName, $value)
 Remove given values from a LDAP attribute.
 
 __set ($name, $value)
 Sets a LDAP attribute.
 
 __unset ($name)
 Deletes a LDAP attribute.
 
 offsetSet ($name, $value)
 Sets a LDAP attribute.
 
 offsetUnset ($name)
 Deletes a LDAP attribute.
 
 exists (Zend_Ldap $ldap=null)
 Check if node exists on LDAP.
 
 reload (Zend_Ldap $ldap=null)
 Reload node attributes from LDAP.
 
 searchSubtree ($filter, $scope=Zend_Ldap::SEARCH_SCOPE_SUB, $sort=null)
 Search current subtree with given options.
 
 countSubtree ($filter, $scope=Zend_Ldap::SEARCH_SCOPE_SUB)
 Count items in current subtree found by given filter.
 
 countChildren ()
 Count children of current node.
 
 searchChildren ($filter, $sort=null)
 Gets children of current node.
 
 hasChildren ()
 Checks if current node has children.
 
 getChildren ()
 Returns the children for the current node.
 
 getParent (Zend_Ldap $ldap=null)
 Returns the parent of the current node.
 
 current ()
 Return the current attribute.
 
 key ()
 Return the attribute name.
 
 next ()
 Move forward to next attribute.
 
 rewind ()
 Rewind the Iterator to the first attribute.
 
 valid ()
 Check if there is a current attribute after calls to rewind() or next().
 
- Public Member Functions inherited from Zend_Ldap_Node_Abstract
 reload (Zend_Ldap $ldap=null)
 Reload node attributes from LDAP.
 
 getDn ()
 Gets the DN of the current node as a Zend_Ldap_Dn.
 
 getDnString ($caseFold=null)
 Gets the DN of the current node as a string.
 
 getDnArray ($caseFold=null)
 Gets the DN of the current node as an array.
 
 getRdnString ($caseFold=null)
 Gets the RDN of the current node as a string.
 
 getRdnArray ($caseFold=null)
 Gets the RDN of the current node as an array.
 
 getObjectClass ()
 Gets the objectClass of the node.
 
 getAttributes ($includeSystemAttributes=true)
 Gets all attributes of node.
 
 toString ()
 Returns the DN of the current node.
 
 __toString ()
 Cast to string representation {.
 
 toArray ($includeSystemAttributes=true)
 Returns an array representation of the current node.
 
 toJson ($includeSystemAttributes=true)
 Returns a JSON representation of the current node.
 
 getData ($includeSystemAttributes=true)
 Gets node attributes.
 
 existsAttribute ($name, $emptyExists=false)
 Checks whether a given attribute exists.
 
 attributeHasValue ($attribName, $value)
 Checks if the given value(s) exist in the attribute.
 
 getAttribute ($name, $index=null)
 Gets a LDAP attribute.
 
 getDateTimeAttribute ($name, $index=null)
 Gets a LDAP date/time attribute.
 
 __set ($name, $value)
 Sets a LDAP attribute.
 
 __get ($name)
 Gets a LDAP attribute.
 
 __unset ($name)
 Deletes a LDAP attribute.
 
 __isset ($name)
 Checks whether a given attribute exists.
 
 offsetSet ($name, $value)
 Sets a LDAP attribute.
 
 offsetGet ($name)
 Gets a LDAP attribute.
 
 offsetUnset ($name)
 Deletes a LDAP attribute.
 
 offsetExists ($name)
 Checks whether a given attribute exists.
 
 count ()
 Returns the number of attributes in node.
 

Static Public Member Functions

static create ($dn, array $objectClass=array())
 Factory method to create a new detached Zend_Ldap_Node for a given DN.
 
static fromLdap ($dn, Zend_Ldap $ldap)
 Factory method to create an attached Zend_Ldap_Node for a given DN.
 
static fromArray (array $data, $fromDataSource=false)
 Factory method to create a detached Zend_Ldap_Node from array data.
 

Protected Member Functions

 __construct (Zend_Ldap_Dn $dn, array $data, $fromDataSource, Zend_Ldap $ldap=null)
 Constructor.
 
 _loadData (array $data, $fromDataSource)
 
 _ensureRdnAttributeValues ($overwrite=false)
 Ensures that teh RDN attributes are correctly set.
 
 _markAsNew ($new)
 Marks this node as new.
 
 _markAsToBeDeleted ($delete)
 Marks this node as to be deleted.
 
 _getDn ()
 Gets the DN of the current node as a Zend_Ldap_Dn.
 
 _setAttribute ($name, $value, $append)
 Checks if the attribute can be set and sets it accordingly.
 
 _setDateTimeAttribute ($name, $value, $utc, $append)
 Checks if the attribute can be set and sets it accordingly.
 
 _assertChangeableAttribute ($name)
 
 _preDelete ()
 Allows pre-delete logic to be applied to node.
 
 _postDelete ()
 Allows post-delete logic to be applied to node.
 
 _preAdd ()
 Allows pre-add logic to be applied to node.
 
 _postAdd ()
 Allows post-add logic to be applied to node.
 
 _preRename ()
 Allows pre-rename logic to be applied to node.
 
 _postRename ()
 Allows post-rename logic to be applied to node.
 
 _preUpdate ()
 Allows pre-update logic to be applied to node.
 
 _postUpdate ()
 Allows post-update logic to be applied to node.
 
- Protected Member Functions inherited from Zend_Ldap_Node_Abstract
 __construct (Zend_Ldap_Dn $dn, array $data, $fromDataSource)
 Constructor.
 
 _loadData (array $data, $fromDataSource)
 
 _getDn ()
 Gets the DN of the current node as a Zend_Ldap_Dn.
 

Protected Attributes

 $_newDn
 
 $_originalData
 
 $_new
 
 $_delete
 
 $_ldap
 
 $_children
 
- Protected Attributes inherited from Zend_Ldap_Node_Abstract
 $_dn
 
 $_currentData
 

Additional Inherited Members

- Static Protected Attributes inherited from Zend_Ldap_Node_Abstract
static $_systemAttributes
 

Constructor & Destructor Documentation

__construct ( Zend_Ldap_Dn  $dn,
array  $data,
  $fromDataSource,
Zend_Ldap  $ldap = null 
)
protected

Constructor.

Constructor is protected to enforce the use of factory methods.

Parameters
Zend_Ldap_Dn$dn
array$data
boolean$fromDataSource
Zend_Ldap$ldap
Exceptions
Zend_Ldap_Exception

Member Function Documentation

__set (   $name,
  $value 
)

Sets a LDAP attribute.

This is an offline method.

Parameters
string$name
mixed$value
Returns
null
Exceptions
Zend_Ldap_Exception
__sleep ( )

Serialization callback.

Only DN and attributes will be serialized.

Returns
array
__unset (   $name)

Deletes a LDAP attribute.

This method deletes the attribute.

This is an offline method.

Parameters
string$name
Returns
null
Exceptions
Zend_Ldap_Exception
__wakeup ( )

Deserialization callback.

Enforces a detached node.

Returns
null
_assertChangeableAttribute (   $name)
protected
Parameters
string$name
Returns
boolean
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
Zend_Ldap_Exception
Zend_Ldap_Exception
_ensureRdnAttributeValues (   $overwrite = false)
protected

Ensures that teh RDN attributes are correctly set.

Parameters
boolean$overwriteTrue to overwrite the RDN attributes
Returns
void
_getDn ( )
protected

Gets the DN of the current node as a Zend_Ldap_Dn.

This is an offline method.

Returns
Zend_Ldap_Dn
_loadData ( array  $data,
  $fromDataSource 
)
protected
Parameters
array$data
boolean$fromDataSource
Exceptions
Zend_Ldap_Exception
_markAsNew (   $new)
protected

Marks this node as new.

Node will be added (instead of updated) on calling update() if $new is true.

Parameters
boolean$new
_markAsToBeDeleted (   $delete)
protected

Marks this node as to be deleted.

Node will be deleted on calling update() if $delete is true.

Parameters
boolean$delete
_postAdd ( )
protected

Allows post-add logic to be applied to node.

Subclasses may override this method.

Returns
void
_postDelete ( )
protected

Allows post-delete logic to be applied to node.

Subclasses may override this method.

Returns
void
_postRename ( )
protected

Allows post-rename logic to be applied to node.

Subclasses may override this method.

Returns
void
_postUpdate ( )
protected

Allows post-update logic to be applied to node.

Subclasses may override this method.

Returns
void
_preAdd ( )
protected

Allows pre-add logic to be applied to node.

Subclasses may override this method.

Returns
void
_preDelete ( )
protected

Allows pre-delete logic to be applied to node.

Subclasses may override this method.

Returns
void
_preRename ( )
protected

Allows pre-rename logic to be applied to node.

Subclasses may override this method.

Returns
void
_preUpdate ( )
protected

Allows pre-update logic to be applied to node.

Subclasses may override this method.

Returns
void
_setAttribute (   $name,
  $value,
  $append 
)
protected

Checks if the attribute can be set and sets it accordingly.

Parameters
string$name
mixed$value
boolean$append
Exceptions
Zend_Ldap_Exception
_setDateTimeAttribute (   $name,
  $value,
  $utc,
  $append 
)
protected

Checks if the attribute can be set and sets it accordingly.

Parameters
string$name
integer | array$value
boolean$utc
boolean$append
Exceptions
Zend_Ldap_Exception
appendObjectClass (   $value)

Appends to the objectClass.

This is an offline method.

Parameters
array | string$value
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
appendToAttribute (   $name,
  $value 
)

Appends to a LDAP attribute.

This is an offline method.

Parameters
string$name
mixed$value
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
appendToDateTimeAttribute (   $name,
  $value,
  $utc = false 
)

Appends to a LDAP date/time attribute.

This is an offline method.

Parameters
string$name
integer | array$value
boolean$utc
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
attachLdap ( Zend_Ldap  $ldap)

Attach node to an LDAP connection.

This is an offline method.

Zend_Ldap_Dn::isChildOf()

Parameters
Zend_Ldap$ldap
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
countChildren ( )

Count children of current node.

This is an online method.

Returns
integer
Exceptions
Zend_Ldap_Exception
countSubtree (   $filter,
  $scope = Zend_Ldap::SEARCH_SCOPE_SUB 
)

Count items in current subtree found by given filter.

This is an online method.

Parameters
string | Zend_Ldap_Filter_Abstract$filter
integer$scope
Returns
integer
Exceptions
Zend_Ldap_Exception
static create (   $dn,
array  $objectClass = array() 
)
static

Factory method to create a new detached Zend_Ldap_Node for a given DN.

Parameters
string | array | Zend_Ldap_Dn$dn
array$objectClass
Returns
Zend_Ldap_Node
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
current ( )

Return the current attribute.

Implements Iterator

Returns
array
delete ( )

Marks this node as to be deleted.

Node will be deleted on calling update() if $delete is true.

Returns
Zend_Ldap_Node Provides a fluid interface
deleteAttribute (   $name)

Deletes a LDAP attribute.

This method deletes the attribute.

This is an offline method.

Parameters
string$name
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
detachLdap ( )

Detach node from LDAP connection.

This is an offline method.

Returns
Zend_Ldap_Node Provides a fluid interface
exists ( Zend_Ldap  $ldap = null)

Check if node exists on LDAP.

This is an online method.

Parameters
Zend_Ldap$ldap
Returns
boolean
Exceptions
Zend_Ldap_Exception
static fromArray ( array  $data,
  $fromDataSource = false 
)
static

Factory method to create a detached Zend_Ldap_Node from array data.

Parameters
array$data
boolean$fromDataSource
Returns
Zend_Ldap_Node
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
Zend_Ldap_Exception
static fromLdap (   $dn,
Zend_Ldap  $ldap 
)
static

Factory method to create an attached Zend_Ldap_Node for a given DN.

Parameters
string | array | Zend_Ldap_Dn$dn
Zend_Ldap$ldap
Returns
Zend_Ldap_Node|null
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
getChangedData ( )

Gets changed node data.

The array contains all changed attributes. This format can be used in Zend_Ldap::add() and Zend_Ldap::update().

This is an offline method.

Returns
array
getChanges ( )

Returns all changes made.

This is an offline method.

Returns
array
getChildren ( )

Returns the children for the current node.

Can be used offline but returns an empty array if children have not been retrieved yet.

Returns
Zend_Ldap_Node_ChildrenIterator
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Node_ChildrenIterator
getCurrentDn ( )

Gets the current DN of the current node as a Zend_Ldap_Dn.

The method returns a clone of the node's DN to prohibit modification.

This is an offline method.

Returns
Zend_Ldap_Dn
getLdap ( )

Gets the current LDAP connection.

Returns
Zend_Ldap
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
getParent ( Zend_Ldap  $ldap = null)

Returns the parent of the current node.

Parameters
Zend_Ldap$ldap
Returns
Zend_Ldap_Node
Exceptions
Zend_Ldap_Exception
hasChildren ( )

Checks if current node has children.

Returns whether the current element has children.

Can be used offline but returns false if children have not been retrieved yet.

Returns
boolean
Exceptions
Zend_Ldap_Exception
isAttached ( )

Checks if the current node is attached to a LDAP server.

This is an offline method.

Returns
boolean
isNew ( )

Tells if the node is consiedered as new (not present on the server)

Please note, that this doesn't tell you if the node is present on the server. Use exits() to see if a node is already there.

Returns
boolean
key ( )

Return the attribute name.

Implements Iterator

Returns
string
move (   $newDn)

{

See Also
setDn()}

This is an offline method.

Parameters
Zend_Ldap_Dn | string | array$newDn
Exceptions
Zend_Ldap_Exception
Returns
Zend_Ldap_Node Provides a fluid interface
next ( )

Move forward to next attribute.

Implements Iterator

offsetSet (   $name,
  $value 
)

Sets a LDAP attribute.

Implements ArrayAccess.

This is an offline method.

Parameters
string$name
mixed$value
Returns
null
Exceptions
Zend_Ldap_Exception
offsetUnset (   $name)

Deletes a LDAP attribute.

Implements ArrayAccess.

This method deletes the attribute.

This is an offline method.

Parameters
string$name
Returns
null
Exceptions
Zend_Ldap_Exception
reload ( Zend_Ldap  $ldap = null)

Reload node attributes from LDAP.

This is an online method.

Parameters
Zend_Ldap$ldap
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
removeDuplicatesFromAttribute (   $attribName)

Removes duplicate values from a LDAP attribute.

Parameters
string$attribName
Returns
void
removeFromAttribute (   $attribName,
  $value 
)

Remove given values from a LDAP attribute.

Parameters
string$attribName
mixed | array$value
Returns
void
rename (   $newDn)

{

See Also
setDn()}

This is an offline method.

Parameters
Zend_Ldap_Dn | string | array$newDn
Exceptions
Zend_Ldap_Exception
Returns
Zend_Ldap_Node Provides a fluid interface
rewind ( )

Rewind the Iterator to the first attribute.

Implements Iterator

searchChildren (   $filter,
  $sort = null 
)

Gets children of current node.

This is an online method.

Parameters
string | Zend_Ldap_Filter_Abstract$filter
string$sort
Returns
Zend_Ldap_Node_Collection
Exceptions
Zend_Ldap_Exception
searchSubtree (   $filter,
  $scope = Zend_Ldap::SEARCH_SCOPE_SUB,
  $sort = null 
)

Search current subtree with given options.

This is an online method.

Parameters
string | Zend_Ldap_Filter_Abstract$filter
integer$scope
string$sort
Returns
Zend_Ldap_Node_Collection
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Node_Collection
setAttribute (   $name,
  $value 
)

Sets a LDAP attribute.

This is an offline method.

Parameters
string$name
mixed$value
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
setDateTimeAttribute (   $name,
  $value,
  $utc = false 
)

Sets a LDAP date/time attribute.

This is an offline method.

Parameters
string$name
integer | array$value
boolean$utc
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
setDn (   $newDn)

Sets the new DN for this node.

This is an offline method.

Parameters
Zend_Ldap_Dn | string | array$newDn
Exceptions
Zend_Ldap_Exception
Returns
Zend_Ldap_Node Provides a fluid interface
setObjectClass (   $value)

Sets the objectClass.

This is an offline method.

Parameters
array | string$value
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
setPasswordAttribute (   $password,
  $hashType = Zend_Ldap_Attribute::PASSWORD_HASH_MD5,
  $attribName = 'userPassword' 
)

Sets a LDAP password.

Parameters
string$password
string$hashType
string$attribName
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
toLdif ( array  $options = array())

Returns a LDIF representation of the current node.

Parameters
array$optionsAdditional options used during encoding
Returns
string

Zend_Ldap_Ldif_Encoder

update ( Zend_Ldap  $ldap = null)

Sends all pending changes to the LDAP server.

Parameters
Zend_Ldap$ldap
Returns
Zend_Ldap_Node Provides a fluid interface
Exceptions
Zend_Ldap_Exception
See Also
Zend_Ldap_Exception
valid ( )

Check if there is a current attribute after calls to rewind() or next().

Implements Iterator

Returns
boolean
willBeDeleted ( )

Is this node going to be deleted once update() is called?

Returns
boolean
willBeMoved ( )

Is this node going to be moved once update() is called?

Returns
boolean

Member Data Documentation

$_children
protected
$_delete
protected
$_ldap
protected
$_new
protected
$_newDn
protected
$_originalData
protected