Zend Framework  2.4
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Node Class Reference

Zend provides an object oriented view into a LDAP node. More...

Public Member Functions

 __sleep ()
 Serialization callback.
 
 __wakeup ()
 Deserialization callback.
 
 getLdap ()
 Gets the current LDAP connection.
 
 attachLdap (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 considered 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 (Ldap $ldap=null)
 Sends all pending changes to the LDAP server.
 
 getCurrentDn ()
 Gets the current DN of the current node as a Zend.
 
 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=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 (Ldap $ldap=null)
 Check if node exists on LDAP.
 
 reload (Ldap $ldap=null)
 Reload node attributes from LDAP.
 
 searchSubtree ($filter, $scope=Ldap::SEARCH_SCOPE_SUB, $sort=null)
 Search current subtree with given options.
 
 countSubtree ($filter, $scope=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 (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 AbstractNode
 reload (Ldap\Ldap $ldap=null)
 Reload node attributes from LDAP.
 
 getDn ()
 Gets the DN of the current node as a Zend.
 
 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 for a given DN.
 
static fromLdap ($dn, Ldap $ldap)
 Factory method to create an attached Zend for a given DN.
 
static fromArray (array $data, $fromDataSource=false)
 Factory method to create a detached Zend from array data.
 

Protected Member Functions

 __construct (Dn $dn, array $data, $fromDataSource, Ldap $ldap=null)
 Constructor.
 
 triggerEvent ($event, $argv=array())
 Trigger an event.
 
 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.
 
 _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)
 
- Protected Member Functions inherited from AbstractNode
 __construct (Ldap\Dn $dn, array $data, $fromDataSource)
 Constructor.
 
 loadData (array $data, $fromDataSource)
 
 _getDn ()
 Gets the DN of the current node as a Zend.
 

Protected Attributes

 $newDn
 
 $originalData
 
 $new
 
 $delete
 
 $ldap
 
 $children
 
 $events
 
- Protected Attributes inherited from AbstractNode
 $dn
 
 $currentData
 

Additional Inherited Members

- Static Protected Attributes inherited from AbstractNode
static $systemAttributes
 

Detailed Description

Zend provides an object oriented view into a LDAP node.

Constructor & Destructor Documentation

__construct ( Dn  $dn,
array  $data,
  $fromDataSource,
Ldap  $ldap = null 
)
protected

Constructor.

Constructor is protected to enforce the use of factory methods.

Parameters
Dn$dn
array$data
bool$fromDataSource
Ldap$ldap
Exceptions
Exception\LdapException

Member Function Documentation

__set (   $name,
  $value 
)

Sets a LDAP attribute.

This is an offline method.

Parameters
string$name
$value
__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
Exceptions
Exception\LdapException
__wakeup ( )

Deserialization callback.

Enforces a detached node.

_getDn ( )
protected

Gets the DN of the current node as a Zend.

This is an offline method.

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

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

Parameters
string$name
mixed$value
bool$append
Exceptions
Exception\LdapException
_setDateTimeAttribute (   $name,
  $value,
  $utc,
  $append 
)
protected

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

Parameters
string$name
int | array$value
bool$utc
bool$append
Exceptions
Exception\LdapException
appendObjectClass (   $value)

Appends to the objectClass.

This is an offline method.

Parameters
array | string$value
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
appendToAttribute (   $name,
  $value 
)

Appends to a LDAP attribute.

This is an offline method.

Parameters
string$name
mixed$value
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
appendToDateTimeAttribute (   $name,
  $value,
  $utc = false 
)

Appends to a LDAP date/time attribute.

This is an offline method.

Parameters
string$name
int | array$value
bool$utc
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
assertChangeableAttribute (   $name)
protected
Parameters
string$name
Returns
bool
Exceptions
Exception\LdapException
attachLdap ( Ldap  $ldap)

Attach node to an LDAP connection.

This is an offline method.

Parameters
Ldap$ldap
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
countChildren ( )

Count children of current node.

This is an online method.

Returns
int
Exceptions
Exception\LdapException
countSubtree (   $filter,
  $scope = Ldap::SEARCH_SCOPE_SUB 
)

Count items in current subtree found by given filter.

This is an online method.

Parameters
string | Filter\AbstractFilter$filter
int$scope
Returns
int
Exceptions
Exception\LdapException
static create (   $dn,
array  $objectClass = array() 
)
static

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

Parameters
string | array | Dn$dn
array$objectClass
Returns
Node
Exceptions
Exception\LdapException
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
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
Node Provides a fluid interface
Exceptions
Exception\LdapException
detachLdap ( )

Detach node from LDAP connection.

This is an offline method.

Returns
Node Provides a fluid interface
ensureRdnAttributeValues (   $overwrite = false)
protected

Ensures that teh RDN attributes are correctly set.

Parameters
bool$overwriteTrue to overwrite the RDN attributes
Returns
void
exists ( Ldap  $ldap = null)

Check if node exists on LDAP.

This is an online method.

Parameters
Ldap$ldap
Returns
bool
Exceptions
Exception\LdapException
static fromArray ( array  $data,
  $fromDataSource = false 
)
static

Factory method to create a detached Zend from array data.

Parameters
array$data
bool$fromDataSource
Returns
Node
Exceptions
Exception\LdapException
static fromLdap (   $dn,
Ldap  $ldap 
)
static

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

Parameters
string | array | Dn$dn
Ldap$ldap
Returns
Node|null
Exceptions
Exception\LdapException
getChangedData ( )

Gets changed node data.

The array contains all changed attributes. This format can be used in ::add() and ::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
Node
Exceptions
Exception\LdapException
getCurrentDn ( )

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

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

This is an offline method.

Returns
Dn
getLdap ( )

Gets the current LDAP connection.

Returns
Ldap
Exceptions
Exception\LdapException
getParent ( Ldap  $ldap = null)

Returns the parent of the current node.

Parameters
Ldap$ldap
Returns
Node
Exceptions
Exception\LdapException
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
bool
Exceptions
Exception\LdapException
isAttached ( )

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

This is an offline method.

Returns
bool
isNew ( )

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

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

Returns
bool
key ( )

Return the attribute name.

Implements Iterator

Returns
string
loadData ( array  $data,
  $fromDataSource 
)
protected
Parameters
array$data
bool$fromDataSource
Exceptions
Exception\LdapException
markAsNew (   $new)
protected

Marks this node as new.

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

Parameters
bool$new
markAsToBeDeleted (   $delete)
protected

Marks this node as to be deleted.

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

Parameters
bool$delete
move (   $newDn)

{

See Also
setDn()}

This is an offline method.

Parameters
Dn | string | array$newDn
Exceptions
Exception\LdapException
Returns
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
Exceptions
Exception\LdapException
offsetUnset (   $name)

Deletes a LDAP attribute.

Implements ArrayAccess.

This method deletes the attribute.

This is an offline method.

Parameters
string$name
Exceptions
Exception\LdapException
reload ( Ldap  $ldap = null)

Reload node attributes from LDAP.

This is an online method.

Parameters
Ldap$ldap
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
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
Dn | string | array$newDn
Exceptions
Exception\LdapException
Returns
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 | Filter\AbstractFilter$filter
string$sort
Returns
Node
Exceptions
Exception\LdapException
searchSubtree (   $filter,
  $scope = Ldap::SEARCH_SCOPE_SUB,
  $sort = null 
)

Search current subtree with given options.

This is an online method.

Parameters
string | Filter\AbstractFilter$filter
int$scope
string$sort
Returns
Node
Exceptions
Exception\LdapException
setAttribute (   $name,
  $value 
)

Sets a LDAP attribute.

This is an offline method.

Parameters
string$name
mixed$value
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
setDateTimeAttribute (   $name,
  $value,
  $utc = false 
)

Sets a LDAP date/time attribute.

This is an offline method.

Parameters
string$name
int | array$value
bool$utc
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
setDn (   $newDn)

Sets the new DN for this node.

This is an offline method.

Parameters
Dn | string | array$newDn
Exceptions
Exception\LdapException
Returns
Node Provides a fluid interface
setObjectClass (   $value)

Sets the objectClass.

This is an offline method.

Parameters
array | string$value
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
setPasswordAttribute (   $password,
  $hashType = Attribute::PASSWORD_HASH_MD5,
  $attribName = 'userPassword' 
)

Sets a LDAP password.

Parameters
string$password
string$hashType
string$attribName
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapException
toLdif ( array  $options = array())

Returns a LDIF representation of the current node.

Parameters
array$optionsAdditional options used during encoding
Returns
string
triggerEvent (   $event,
  $argv = array() 
)
protected

Trigger an event.

Parameters
string$eventEvent name
array | \ArrayAccess$argvArray of arguments; typically, should be associative
update ( Ldap  $ldap = null)

Sends all pending changes to the LDAP server.

Parameters
Ldap$ldap
Returns
Node Provides a fluid interface
Exceptions
Exception\LdapExceptionpre-delete post-delete pre-add post-add pre-rename post-rename pre-update post-update
valid ( )

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

Implements Iterator

Returns
bool
willBeDeleted ( )

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

Returns
bool
willBeMoved ( )

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

Returns
bool

Member Data Documentation

$children
protected
$delete
protected
$events
protected
$ldap
protected
$new
protected
$newDn
protected
$originalData
protected