1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.ldap.api.reference.zend-ldap-node">
4 <title>Zend_Ldap_Node</title>
7 <classname>Zend_Ldap_Node</classname> includes the magic property accessors
8 <methodname>__set()</methodname>, <methodname>__get()</methodname>,
9 <methodname>__unset()</methodname> and <methodname>__isset()</methodname> to access the
10 attributes by their name. They proxy to
11 <methodname>Zend_Ldap_Node::setAttribute()</methodname>,
12 <methodname>Zend_Ldap_Node::getAttribute()</methodname>,
13 <methodname>Zend_Ldap_Node::deleteAttribute()</methodname> and
14 <methodname>Zend_Ldap_Node::existsAttribute()</methodname> respectively. Furthermore the
15 class implements <code>ArrayAccess</code> for array-style-access to the attributes.
16 <classname>Zend_Ldap_Node</classname> also implements <code>Iterator</code> and
17 <code>RecursiveIterato</code> to allow for recursive tree-traversal.
20 <table id="zend.ldap.api.reference.zend-ldap-node.table">
21 <title>Zend_Ldap_Node API</title>
27 <entry>Description</entry>
33 <entry><code>Zend_Ldap getLdap()</code></entry>
36 Returns the current <acronym>LDAP</acronym> connection. Throws
37 <classname>Zend_Ldap_Exception</classname> if current node is in detached
38 mode (not connected to a <classname>Zend_Ldap</classname> instance).
43 <entry><code>Zend_Ldap_Node attachLdap(Zend_Ldap $ldap)</code></entry>
46 Attach the current node to the <varname>$ldap</varname>
47 <classname>Zend_Ldap</classname> instance. Throws
48 <classname>Zend_Ldap_Exception</classname> if <varname>$ldap</varname> is
49 not responsible for the current node (node is not a child of the
50 <varname>$ldap</varname> base DN).
55 <entry><code>Zend_Ldap_Node detachLdap()</code></entry>
56 <entry>Detach node from <acronym>LDAP</acronym> connection.</entry>
60 <entry><code>boolean isAttached()</code></entry>
63 Checks if the current node is attached to a <acronym>LDAP</acronym>
70 <emphasis><code>Zend_Ldap_Node create(string|array|Zend_Ldap_Dn $dn, array
71 $objectClass)</code></emphasis>
75 Factory method to create a new detached
76 <classname>Zend_Ldap_Node</classname> for a given DN. Creates a new
77 <classname>Zend_Ldap_Node</classname> with the DN <varname>$dn</varname> and
78 the object-classes <varname>$objectClass</varname>.
84 <emphasis><code>Zend_Ldap_Node fromLdap(string|array|Zend_Ldap_Dn $dn,
85 Zend_Ldap $ldap)</code></emphasis>
89 Factory method to create an attached
90 <classname>Zend_Ldap_Node</classname> for a given DN. Loads an existing
91 <classname>Zend_Ldap_Node</classname> with the DN <varname>$dn</varname>
92 from the <acronym>LDAP</acronym> connection <varname>$ldap</varname>.
98 <emphasis><code>Zend_Ldap_Node fromArray((array $data,
99 boolean $fromDataSource)</code></emphasis>
103 Factory method to create a detached <classname>Zend_Ldap_Node</classname>
104 from array data <varname>$data</varname>. if
105 <varname>$fromDataSource</varname> is <constant>TRUE</constant>
106 (<constant>FALSE</constant> by default), the data is treated as beeing
107 present in a <acronym>LDAP</acronym> tree.
112 <entry><code>boolean isNew()</code></entry>
115 Tells if the node is consiedered as new (not present on the
116 server). Please note, that this doesn't tell if the node is really
117 present on the server. Use <methodname>Zend_Ldap_Node::exists()</methodname>
118 to see if a node is already there.
123 <entry><code>boolean willBeDeleted()</code></entry>
126 Tells if this node is going to be deleted once
127 <methodname>Zend_Ldap_Node::update()</methodname> is called.
132 <entry><code>Zend_Ldap_Node delete()</code></entry>
135 Marks this node as to be deleted. Node will be deleted on
136 calling <methodname>Zend_Ldap_Node::update()</methodname> if
137 <methodname>Zend_Ldap_Node::willBeDeleted()</methodname> is
138 <constant>TRUE</constant>.
143 <entry><code>boolean willBeMoved()</code></entry>
146 Tells if this node is going to be moved once
147 <methodname>Zend_Ldap_Node::update()</methodname> is called.
152 <entry><code>Zend_Ldap_Node update(Zend_Ldap $ldap)</code></entry>
155 Sends all pending changes to the <acronym>LDAP</acronym> server. If
156 <varname>$ldap</varname> is omitted the current <acronym>LDAP</acronym>
157 connection is used. If the current node is detached from a
158 <acronym>LDAP</acronym> connection a
159 <classname>Zend_Ldap_Exception</classname> will be thrown. If
160 <varname>$ldap</varname> is provided the current node will be attached to
161 the given <acronym>LDAP</acronym> connection.
166 <entry><code>Zend_Ldap_Dn getCurrentDn()</code></entry>
169 Gets the current DN of the current node as a
170 <classname>Zend_Ldap_Dn</classname>. This does not reflect possible
176 <entry><code>Zend_Ldap_Dn getDn()</code></entry>
179 Gets the original DN of the current node as a
180 <classname>Zend_Ldap_Dn</classname>. This reflects possible
186 <entry><code>string getDnString(string $caseFold)</code></entry>
189 Gets the original DN of the current node as a string. This
190 reflects possible rename-operations.
195 <entry><code>array getDnArray(string $caseFold)</code></entry>
198 Gets the original DN of the current node as an array. This
199 reflects possible rename-operations.
204 <entry><code>string getRdnString(string $caseFold)</code></entry>
207 Gets the <acronym>RDN</acronym> of the current node as a string. This
208 reflects possible rename-operations.
213 <entry><code>array getRdnArray(string $caseFold)</code></entry>
216 Gets the <acronym>RDN</acronym> of the current node as an array. This
217 reflects possible rename-operations.
223 <code>Zend_Ldap_Node setDn(Zend_Ldap_Dn|string|array $newDn)</code>
227 Sets the new DN for this node effectively moving the node
228 once <methodname>Zend_Ldap_Node::update()</methodname> is called.
234 <code>Zend_Ldap_Node move(Zend_Ldap_Dn|string|array $newDn)</code>
238 This is an alias for <methodname>Zend_Ldap_Node::setDn()</methodname>.
244 <code>Zend_Ldap_Node rename(Zend_Ldap_Dn|string|array $newDn)</code>
248 This is an alias for <methodname>Zend_Ldap_Node::setDn()</methodname>.
253 <entry><code>array getObjectClass()</code></entry>
254 <entry>Returns the objectClass of the node.</entry>
258 <entry><code>Zend_Ldap_Node setObjectClass(array|string $value)</code></entry>
259 <entry>Sets the objectClass attribute.</entry>
264 <code>Zend_Ldap_Node appendObjectClass(array|string $value)</code>
267 <entry>Appends to the objectClass attribute.</entry>
271 <entry><code>string toLdif(array $options)</code></entry>
274 Returns a <acronym>LDIF</acronym> representation of the current node.
275 <varname>$options</varname> will be passed to the
276 <classname>Zend_Ldap_Ldif_Encoder</classname>.
281 <entry><code>array getChangedData()</code></entry>
284 Gets changed node data. The array contains all changed
285 attributes. This format can be used in
286 <methodname>Zend_Ldap::add()</methodname> and
287 <methodname>Zend_Ldap::update()</methodname>.
292 <entry><code>array getChanges()</code></entry>
293 <entry>Returns all changes made.</entry>
297 <entry><code>string toString()</code></entry>
300 Returns the DN of the current node - proxies to
301 <methodname>Zend_Ldap_Dn::getDnString()</methodname>.
306 <entry><code>string __toString()</code></entry>
309 Casts to string representation - proxies to
310 <methodname>Zend_Ldap_Dn::toString()</methodname>.
315 <entry><code>array toArray(boolean $includeSystemAttributes)</code></entry>
318 Returns an array representation of the current node. If
319 <varname>$includeSystemAttributes</varname> is <constant>FALSE</constant>
320 (defaults to <constant>TRUE</constant>) the system specific attributes are
321 stripped from the array. Unlike
322 <methodname>Zend_Ldap_Node::getAttributes()</methodname> the resulting array
323 contains the DN with key <code>'dn'</code>.
328 <entry><code>string toJson(boolean $includeSystemAttributes)</code></entry>
331 Returns a <acronym>JSON</acronym> representation of the current node using
332 <methodname>Zend_Ldap_Node::toArray()</methodname>.
337 <entry><code>array getData(boolean $includeSystemAttributes)</code></entry>
340 Returns the node's attributes. The array contains all
341 attributes in its internal format (no conversion).
347 <code>boolean existsAttribute(string $name, boolean $emptyExists)</code>
351 Checks whether a given attribute exists. If
352 <varname>$emptyExists</varname> is <constant>FALSE</constant> empty
353 attributes (containing only array()) are treated as non-existent returning
354 <constant>FALSE</constant>. If <varname>$emptyExists</varname> is
355 <constant>TRUE</constant> empty attributes are treated as existent returning
356 <constant>TRUE</constant>. In this case the method returns
357 <constant>FALSE</constant> only if the attribute name is missing in the
364 <code>boolean attributeHasValue(string $name, mixed|array $value)</code>
368 Checks if the given value(s) exist in the attribute. The
369 method returns <constant>TRUE</constant> only if all values in
370 <varname>$value</varname> are present in the attribute. Comparison is
371 done strictly (respecting the data type).
376 <entry><code>integer count()</code></entry>
379 Returns the number of attributes in the node. Implements Countable.
385 <code>mixed getAttribute(string $name, integer|null $index)</code>
389 Gets a <acronym>LDAP</acronym> attribute. Data conversion is applied using
390 <methodname>Zend_Ldap_Attribute::getAttribute()</methodname>.
396 <code>array getAttributes(boolean $includeSystemAttributes)</code>
400 Gets all attributes of node. If
401 <varname>$includeSystemAttributes</varname> is <constant>FALSE</constant>
402 (defaults to <constant>TRUE</constant>) the system specific attributes are
403 stripped from the array.
409 <code>Zend_Ldap_Node setAttribute(string $name, mixed $value)</code>
413 Sets a <acronym>LDAP</acronym> attribute. Data conversion is applied using
414 <methodname>Zend_Ldap_Attribute::setAttribute()</methodname>.
420 <code>Zend_Ldap_Node appendToAttribute(string $name, mixed $value)</code>
424 Appends to a <acronym>LDAP</acronym> attribute. Data conversion is applied
425 using <methodname>Zend_Ldap_Attribute::setAttribute()</methodname>.
431 <code>array|integer getDateTimeAttribute(string $name,
432 integer|null $index)</code>
436 Gets a <acronym>LDAP</acronym> date/time attribute. Data conversion is
438 <methodname>Zend_Ldap_Attribute::getDateTimeAttribute()</methodname>.
444 <code>Zend_Ldap_Node setDateTimeAttribute(string $name,
445 integer|array $value, boolean $utc)</code>
449 Sets a <acronym>LDAP</acronym> date/time attribute. Data conversion is
451 <methodname>Zend_Ldap_Attribute::setDateTimeAttribute()</methodname>.
457 <code>Zend_Ldap_Node appendToDateTimeAttribute(string $name,
458 integer|array $value, boolean $utc)</code>
462 Appends to a <acronym>LDAP</acronym> date/time attribute. Data conversion is
464 <methodname>Zend_Ldap_Attribute::setDateTimeAttribute()</methodname>.
470 <code>Zend_Ldap_Node setPasswordAttribute(string $password,
471 string $hashType, string $attribName)</code>
475 Sets a <acronym>LDAP</acronym> password on <varname>$attribName</varname>
476 (defaults to <code>'userPassword'</code>) to <varname>$password</varname>
477 with the hash type <varname>$hashType</varname> (defaults to
478 <constant>Zend_Ldap_Attribute::PASSWORD_HASH_MD5</constant>).
483 <entry><code>Zend_Ldap_Node deleteAttribute(string $name)</code></entry>
484 <entry>Deletes a <acronym>LDAP</acronym> attribute.</entry>
488 <entry><code>void removeDuplicatesFromAttribute(string$name)</code></entry>
491 Removes duplicate values from a <acronym>LDAP</acronym> attribute.
497 <code>void removeFromAttribute(string $attribName,
498 mixed|array $value)</code>
502 Removes the given values from a <acronym>LDAP</acronym> attribute.
507 <entry><code>boolean exists(Zend_Ldap $ldap)</code></entry>
510 Checks if the current node exists on the given <acronym>LDAP</acronym>
511 server (current server is used if <constant>NULL</constant> is passed).
516 <entry><code>Zend_Ldap_Node reload(Zend_Ldap $ldap)</code></entry>
519 Reloads the current node's attributes from the given <acronym>LDAP</acronym>
520 server (current server is used if <constant>NULL</constant> is
527 <code>Zend_Ldap_Node_Collection
528 searchSubtree(string|Zend_Ldap_Filter_Abstract $filter, integer
529 $scope, string $sort)</code>
533 Searches the nodes's subtree with the given
534 <varname>$filter</varname> and the given search parameters. See
535 <methodname>Zend_Ldap::search()</methodname> for details on the parameters
536 <varname>$scope</varname> and <varname>$sort</varname>.
542 <code>integer countSubtree(string|Zend_Ldap_Filter_Abstract
543 $filter, integer $scope)</code>
547 Count the nodes's subtree items matching the given
548 <varname>$filter</varname> and the given search scope. See
549 <methodname>Zend_Ldap::search()</methodname> for details on the
550 <varname>$scope</varname> parameter.
555 <entry><code>integer countChildren()</code></entry>
556 <entry>Count the nodes's children.</entry>
561 <code>Zend_Ldap_Node_Collection
562 searchChildren(string|Zend_Ldap_Filter_Abstract $filter, string
567 Searches the nodes's children matching the given
568 <varname>$filter</varname>. See <methodname>Zend_Ldap::search()</methodname>
569 for details on the <varname>$sort</varname> parameter.
574 <entry><code>boolean hasChildren()</code></entry>
575 <entry>Returns whether the current node has children.</entry>
579 <entry><code>Zend_Ldap_Node_ChildrenIterator getChildren()</code></entry>
580 <entry>Returns all children of the current node.</entry>
584 <entry><code>Zend_Ldap_Node getParent(Zend_Ldap $ldap)</code></entry>
587 Returns the parent of the current node using the <acronym>LDAP</acronym>
588 connection <varname>$ldap</varname> (uses the current
589 <acronym>LDAP</acronym> connection if omitted).