Zend_Ldap_Node
Zend_Ldap_Node includes the magic propery accessors
__set(), __get(), __unset() and
__isset() to access the attributes by their name. They proxy to
Zend_Ldap_Node::setAttribute(),
Zend_Ldap_Node::getAttribute(),
Zend_Ldap_Node::deleteAttribute() and
Zend_Ldap_Node::existsAttribute() respectively. Furthermore the class
implements ArrayAccess for array-style-access to the attributes.
Zend_Ldap_Node also implements Iterator and
RecursiveIterato to allow for recursive tree-traversal.
Zend_Ldap_Node API
Method
Description
Zend_Ldap getLdap()
Returns the current LDAP connection. Throws
Zend_Ldap_Exception if current node is in detached
mode (not connected to a Zend_Ldap instance).
Zend_Ldap_Node attachLdap(Zend_Ldap
$ldap)
Attach the current node to the $ldap
Zend_Ldap instance. Throws
Zend_Ldap_Exception if $ldap is not
responsible for the current node (node is not a child of the
$ldap base DN).
Zend_Ldap_Node detachLdap()
Detach node from LDAP connection.
boolean isAttached()
Checks if the current node is attached to a LDAP
connection.
Zend_Ldap_Node
create(string|array|Zend_Ldap_Dn $dn, array $objectClass)
Factory method to create a new detached
Zend_Ldap_Node for a given DN. Creates a new
Zend_Ldap_Node with the DN $dn and the
object-classes $objectClass.
Zend_Ldap_Node
fromLdap(string|array|Zend_Ldap_Dn $dn, Zend_Ldap $ldap)
Factory method to create an attached
Zend_Ldap_Node for a given DN. Loads an existing
Zend_Ldap_Node with the DN $dn from the
LDAP connection $ldap.
Zend_Ldap_Node fromArray((array $data,
boolean $fromDataSource)
Factory method to create a detached
Zend_Ldap_Node from array data $data. If
$fromDataSource is true
(false by default), the data is treated as beeing
present in a LDAP tree.
boolean isNew()
Tells if the node is consiedered as new (not present on the
server). Please note, that this doesn't tell if the node is really
present on the server. Use Zend_Ldap_Node::exists() to
see if a node is already there.
boolean willBeDeleted()
Tells if this node is going to be deleted once
Zend_Ldap_Node::update() is called.
Zend_Ldap_Node delete()
Marks this node as to be deleted. Node will be deleted on
calling Zend_Ldap_Node::update() if
Zend_Ldap_Node::willBeDeleted() is true.
boolean willBeMoved()
Tells if this node is going to be moved once
Zend_Ldap_Node::update() is called.
Zend_Ldap_Node update(Zend_Ldap $ldap)
Sends all pending changes to the LDAP server. If
$ldap is omitted the current LDAP connection is used.
If the current node is detached from a LDAP connection a
Zend_Ldap_Exception will be thrown. If
$ldap is provided the current node will be attached to
the given LDAP connection.
Zend_Ldap_Dn getCurrentDn()
Gets the current DN of the current node as a Zend_Ldap_Dn.
This does not reflect possible rename-operations.
Zend_Ldap_Dn getDn()
Gets the original DN of the current node as a Zend_Ldap_Dn.
This reflects possible rename-operations.
string getDnString(string $caseFold)
Gets the original DN of the current node as a string. This
reflects possible rename-operations.
array getDnArray(string $caseFold)
Gets the original DN of the current node as an array. This
reflects possible rename-operations.
string getRdnString(string $caseFold)
Gets the RDN of the current node as a string. This reflects
possible rename-operations.
array getRdnArray(string $caseFold)
Gets the RDN of the current node as an array. This reflects
possible rename-operations.
Zend_Ldap_Node setDn(Zend_Ldap_Dn|string|array
$newDn)
Sets the new DN for this node effectively moving the node
once Zend_Ldap_Node::update() is called.
Zend_Ldap_Node move(Zend_Ldap_Dn|string|array
$newDn)
This is an alias for
Zend_Ldap_Node::setDn().
Zend_Ldap_Node rename(Zend_Ldap_Dn|string|array
$newDn)
This is an alias for
Zend_Ldap_Node::setDn().
array getObjectClass()
Returns the objectClass of the node.
Zend_Ldap_Node setObjectClass(array|string
$value)
Sets the objectClass attribute.
Zend_Ldap_Node appendObjectClass(array|string
$value)
Appends to the objectClass attribute.
string toLdif(array $options)
Returns a LDIF representation of the current node.
$options will be passed to the
Zend_Ldap_Ldif_Encoder.
array getChangedData()
Gets changed node data. The array contains all changed
attributes. This format can be used in
Zend_Ldap::add() and
Zend_Ldap::update().
array getChanges()
Returns all changes made.
string toString()
Returns the DN of the current node - proxies to
Zend_Ldap_Dn::getDnString().
string __toString()
Casts to string representation - proxies to
Zend_Ldap_Dn::toString().
array toArray(boolean
$includeSystemAttributes)
Returns an array representation of the current node. If
$includeSystemAttributes is false
(defaults to true) the system specific attributes are
stripped from the array. Unlike
Zend_Ldap_Node::getAttributes() the resulting array
contains the DN with key 'dn'.
string toJson(boolean
$includeSystemAttributes)
Returns a JSON representation of the current node using
Zend_Ldap_Node::toArray().
array getData(boolean
$includeSystemAttributes)
Returns the node's attributes. The array contains all
attributes in its internal format (no conversion).
boolean existsAttribute(string $name, boolean
$emptyExists)
Checks whether a given attribute exists. If
$emptyExists is false empty attributes
(containing only array()) are treated as non-existent returning
false. If $emptyExists is true empty
attributes are treated as existent returning true. In
this case teh method returns false only if the
attribute name is missing in the key-collection.
boolean attributeHasValue(string $name, mixed|array
$value)
Checks if the given value(s) exist in the attribute. The
method returns true only if all values in
$value are present in the attribute. Comparison is
done strictly (respecting the data type).
integer count()
Returns the number of attributes in the node. Implements
Countable.
mixed getAttribute(string $name, integer|null
$index)
Gets a LDAP attribute. Data conversion is applied using
Zend_Ldap_Attribute::getAttribute().
array getAttributes(boolean
$includeSystemAttributes)
Gets all attributes of node. If
$includeSystemAttributes is false
(defaults to true) the system specific attributes are
stripped from the array.
Zend_Ldap_Node setAttribute(string $name, mixed
$value)
Sets a LDAP attribute. Data conversion is applied using
Zend_Ldap_Attribute::setAttribute().
Zend_Ldap_Node appendToAttribute(string $name, mixed
$value)
Appends to a LDAP attribute. Data conversion is applied
using Zend_Ldap_Attribute::setAttribute().
array|integer getDateTimeAttribute(string $name,
integer|null $index)
Gets a LDAP date/time attribute. Data conversion is applied
using
Zend_Ldap_Attribute::getDateTimeAttribute().
Zend_Ldap_Node setDateTimeAttribute(string $name,
integer|array $value, boolean $utc)
Sets a LDAP date/time attribute. Data conversion is applied
using
Zend_Ldap_Attribute::setDateTimeAttribute().
Zend_Ldap_Node appendToDateTimeAttribute(string $name,
integer|array $value, boolean $utc)
Appends to a LDAP date/time attribute. Data conversion is
applied using
Zend_Ldap_Attribute::setDateTimeAttribute().
Zend_Ldap_Node setPasswordAttribute(string $password,
string $hashType, string $attribName)
Sets a LDAP password on $attribName (defaults
to 'userPassword') to $password with the
hash type $hashType (defaults to
Zend_Ldap_Attribute::PASSWORD_HASH_MD5).
Zend_Ldap_Node deleteAttribute(string
$name)
Deletes a LDAP attribute.
void removeDuplicatesFromAttribute(string
$name)
Removes duplicate values from a LDAP attribute.
void removeFromAttribute(string $attribName,
mixed|array $value)
Removes the given values from a LDAP attribute.
boolean exists(Zend_Ldap $ldap)
Checks if the current node exists on the given LDAP server
(current server is used if null is passed).
Zend_Ldap_Node reload(Zend_Ldap $ldap)
Reloads the current node's attributes from the given LDAP
server (current server is used if null is
passed).
Zend_Ldap_Node_Collection
searchSubtree(string|Zend_Ldap_Filter_Abstract $filter, integer
$scope, string $sort)
Searches the nodes's subtree with the given
$filter and the given search parameters. See
Zend_Ldap::search() for details on the parameters
$scope and $sort.
integer countSubtree(string|Zend_Ldap_Filter_Abstract
$filter, integer $scope)
Count the nodes's subtree items matching the given
$filter and the given search scope. See
Zend_Ldap::search() for details on the
$scope parameter.
integer countChildren()
Count the nodes's children.
Zend_Ldap_Node_Collection
searchChildren(string|Zend_Ldap_Filter_Abstract $filter, string
$sort)
Searches the nodes's children matching the given
$filter. See Zend_Ldap::search() for
details on the $sort parameter.
boolean hasChildren()
Returns whether the current node has children.
Zend_Ldap_Node_ChildrenIterator
getChildren()
Returns all children of the current node.
Zend_Ldap_Node getParent(Zend_Ldap
$ldap)
Returns the parent of the current node using the LDAP
connection $ldap (uses the current LDAP connection if
omitted).