web/lib/Zend/Ldap/Node.php
changeset 1230 68c69c656a2c
parent 807 877f952ae2bd
equal deleted inserted replaced
1229:5a6b6e770365 1230:68c69c656a2c
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Ldap
    16  * @package    Zend_Ldap
    17  * @subpackage Node
    17  * @subpackage Node
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @version    $Id: Node.php 24610 2012-01-21 13:54:27Z sgehrig $
    20  * @version    $Id$
    21  */
    21  */
    22 
    22 
    23 /**
    23 /**
    24  * @see Zend_Ldap
    24  * @see Zend_Ldap
    25  */
    25  */
    33  * Zend_Ldap_Node provides an object oriented view into a LDAP node.
    33  * Zend_Ldap_Node provides an object oriented view into a LDAP node.
    34  *
    34  *
    35  * @category   Zend
    35  * @category   Zend
    36  * @package    Zend_Ldap
    36  * @package    Zend_Ldap
    37  * @subpackage Node
    37  * @subpackage Node
    38  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    38  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
    39  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    39  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    40  */
    40  */
    41 class Zend_Ldap_Node extends Zend_Ldap_Node_Abstract implements Iterator, RecursiveIterator
    41 class Zend_Ldap_Node extends Zend_Ldap_Node_Abstract implements Iterator, RecursiveIterator
    42 {
    42 {
    43     /**
    43     /**
   151      *
   151      *
   152      * This is an offline method.
   152      * This is an offline method.
   153      *
   153      *
   154      * @uses   Zend_Ldap_Dn::isChildOf()
   154      * @uses   Zend_Ldap_Dn::isChildOf()
   155      * @param  Zend_Ldap $ldap
   155      * @param  Zend_Ldap $ldap
   156      * @return Zend_Ldap_Node Provides a fluid interface
   156      * @return Zend_Ldap_Node Provides a fluent interface
   157      * @throws Zend_Ldap_Exception
   157      * @throws Zend_Ldap_Exception
   158      */
   158      */
   159     public function attachLdap(Zend_Ldap $ldap)
   159     public function attachLdap(Zend_Ldap $ldap)
   160     {
   160     {
   161         if (!Zend_Ldap_Dn::isChildOf($this->_getDn(), $ldap->getBaseDn())) {
   161         if (!Zend_Ldap_Dn::isChildOf($this->_getDn(), $ldap->getBaseDn())) {
   182     /**
   182     /**
   183      * Detach node from LDAP connection
   183      * Detach node from LDAP connection
   184      *
   184      *
   185      * This is an offline method.
   185      * This is an offline method.
   186      *
   186      *
   187      * @return Zend_Ldap_Node Provides a fluid interface
   187      * @return Zend_Ldap_Node Provides a fluent interface
   188      */
   188      */
   189     public function detachLdap()
   189     public function detachLdap()
   190     {
   190     {
   191         $this->_ldap = null;
   191         $this->_ldap = null;
   192         if (is_array($this->_children)) {
   192         if (is_array($this->_children)) {
   386     /**
   386     /**
   387      * Marks this node as to be deleted
   387      * Marks this node as to be deleted
   388      *
   388      *
   389      * Node will be deleted on calling update() if $delete is true.
   389      * Node will be deleted on calling update() if $delete is true.
   390      *
   390      *
   391      * @return Zend_Ldap_Node Provides a fluid interface
   391      * @return Zend_Ldap_Node Provides a fluent interface
   392      */
   392      */
   393     public function delete()
   393     public function delete()
   394     {
   394     {
   395         $this->_markAsToBeDeleted(true);
   395         $this->_markAsToBeDeleted(true);
   396         return $this;
   396         return $this;
   414 
   414 
   415     /**
   415     /**
   416      * Sends all pending changes to the LDAP server
   416      * Sends all pending changes to the LDAP server
   417      *
   417      *
   418      * @param  Zend_Ldap $ldap
   418      * @param  Zend_Ldap $ldap
   419      * @return Zend_Ldap_Node Provides a fluid interface
   419      * @return Zend_Ldap_Node Provides a fluent interface
   420      * @throws Zend_Ldap_Exception
   420      * @throws Zend_Ldap_Exception
   421      */
   421      */
   422     public function update(Zend_Ldap $ldap = null)
   422     public function update(Zend_Ldap $ldap = null)
   423     {
   423     {
   424         if ($ldap !== null) {
   424         if ($ldap !== null) {
   505      *
   505      *
   506      * This is an offline method.
   506      * This is an offline method.
   507      *
   507      *
   508      * @param  Zend_Ldap_Dn|string|array $newDn
   508      * @param  Zend_Ldap_Dn|string|array $newDn
   509      * @throws Zend_Ldap_Exception
   509      * @throws Zend_Ldap_Exception
   510      * @return Zend_Ldap_Node Provides a fluid interface
   510      * @return Zend_Ldap_Node Provides a fluent interface
   511      */
   511      */
   512     public function setDn($newDn)
   512     public function setDn($newDn)
   513     {
   513     {
   514         if ($newDn instanceof Zend_Ldap_Dn) {
   514         if ($newDn instanceof Zend_Ldap_Dn) {
   515             $this->_newDn = clone $newDn;
   515             $this->_newDn = clone $newDn;
   525      *
   525      *
   526      * This is an offline method.
   526      * This is an offline method.
   527      *
   527      *
   528      * @param  Zend_Ldap_Dn|string|array $newDn
   528      * @param  Zend_Ldap_Dn|string|array $newDn
   529      * @throws Zend_Ldap_Exception
   529      * @throws Zend_Ldap_Exception
   530      * @return Zend_Ldap_Node Provides a fluid interface
   530      * @return Zend_Ldap_Node Provides a fluent interface
   531      */
   531      */
   532     public function move($newDn)
   532     public function move($newDn)
   533     {
   533     {
   534         return $this->setDn($newDn);
   534         return $this->setDn($newDn);
   535     }
   535     }
   539      *
   539      *
   540      * This is an offline method.
   540      * This is an offline method.
   541      *
   541      *
   542      * @param  Zend_Ldap_Dn|string|array $newDn
   542      * @param  Zend_Ldap_Dn|string|array $newDn
   543      * @throws Zend_Ldap_Exception
   543      * @throws Zend_Ldap_Exception
   544      * @return Zend_Ldap_Node Provides a fluid interface
   544      * @return Zend_Ldap_Node Provides a fluent interface
   545      */
   545      */
   546     public function rename($newDn)
   546     public function rename($newDn)
   547     {
   547     {
   548         return $this->setDn($newDn);
   548         return $this->setDn($newDn);
   549     }
   549     }
   552      * Sets the objectClass.
   552      * Sets the objectClass.
   553      *
   553      *
   554      * This is an offline method.
   554      * This is an offline method.
   555      *
   555      *
   556      * @param  array|string $value
   556      * @param  array|string $value
   557      * @return Zend_Ldap_Node Provides a fluid interface
   557      * @return Zend_Ldap_Node Provides a fluent interface
   558      * @throws Zend_Ldap_Exception
   558      * @throws Zend_Ldap_Exception
   559      */
   559      */
   560     public function setObjectClass($value)
   560     public function setObjectClass($value)
   561     {
   561     {
   562         $this->setAttribute('objectClass', $value);
   562         $this->setAttribute('objectClass', $value);
   567      * Appends to the objectClass.
   567      * Appends to the objectClass.
   568      *
   568      *
   569      * This is an offline method.
   569      * This is an offline method.
   570      *
   570      *
   571      * @param  array|string $value
   571      * @param  array|string $value
   572      * @return Zend_Ldap_Node Provides a fluid interface
   572      * @return Zend_Ldap_Node Provides a fluent interface
   573      * @throws Zend_Ldap_Exception
   573      * @throws Zend_Ldap_Exception
   574      */
   574      */
   575     public function appendObjectClass($value)
   575     public function appendObjectClass($value)
   576     {
   576     {
   577         $this->appendToAttribute('objectClass', $value);
   577         $this->appendToAttribute('objectClass', $value);
   651      *
   651      *
   652      * This is an offline method.
   652      * This is an offline method.
   653      *
   653      *
   654      * @param  string $name
   654      * @param  string $name
   655      * @param  mixed  $value
   655      * @param  mixed  $value
   656      * @return Zend_Ldap_Node Provides a fluid interface
   656      * @return Zend_Ldap_Node Provides a fluent interface
   657      * @throws Zend_Ldap_Exception
   657      * @throws Zend_Ldap_Exception
   658      */
   658      */
   659     public function setAttribute($name, $value)
   659     public function setAttribute($name, $value)
   660     {
   660     {
   661         $this->_setAttribute($name, $value, false);
   661         $this->_setAttribute($name, $value, false);
   667      *
   667      *
   668      * This is an offline method.
   668      * This is an offline method.
   669      *
   669      *
   670      * @param  string $name
   670      * @param  string $name
   671      * @param  mixed  $value
   671      * @param  mixed  $value
   672      * @return Zend_Ldap_Node Provides a fluid interface
   672      * @return Zend_Ldap_Node Provides a fluent interface
   673      * @throws Zend_Ldap_Exception
   673      * @throws Zend_Ldap_Exception
   674      */
   674      */
   675     public function appendToAttribute($name, $value)
   675     public function appendToAttribute($name, $value)
   676     {
   676     {
   677         $this->_setAttribute($name, $value, true);
   677         $this->_setAttribute($name, $value, true);
   698      * This is an offline method.
   698      * This is an offline method.
   699      *
   699      *
   700      * @param  string        $name
   700      * @param  string        $name
   701      * @param  integer|array $value
   701      * @param  integer|array $value
   702      * @param  boolean       $utc
   702      * @param  boolean       $utc
   703      * @return Zend_Ldap_Node Provides a fluid interface
   703      * @return Zend_Ldap_Node Provides a fluent interface
   704      * @throws Zend_Ldap_Exception
   704      * @throws Zend_Ldap_Exception
   705      */
   705      */
   706     public function setDateTimeAttribute($name, $value, $utc = false)
   706     public function setDateTimeAttribute($name, $value, $utc = false)
   707     {
   707     {
   708         $this->_setDateTimeAttribute($name, $value, $utc, false);
   708         $this->_setDateTimeAttribute($name, $value, $utc, false);
   715      * This is an offline method.
   715      * This is an offline method.
   716      *
   716      *
   717      * @param  string        $name
   717      * @param  string        $name
   718      * @param  integer|array $value
   718      * @param  integer|array $value
   719      * @param  boolean       $utc
   719      * @param  boolean       $utc
   720      * @return Zend_Ldap_Node Provides a fluid interface
   720      * @return Zend_Ldap_Node Provides a fluent interface
   721      * @throws Zend_Ldap_Exception
   721      * @throws Zend_Ldap_Exception
   722      */
   722      */
   723     public function appendToDateTimeAttribute($name, $value, $utc = false)
   723     public function appendToDateTimeAttribute($name, $value, $utc = false)
   724     {
   724     {
   725         $this->_setDateTimeAttribute($name, $value, $utc, true);
   725         $this->_setDateTimeAttribute($name, $value, $utc, true);
   745      * Sets a LDAP password.
   745      * Sets a LDAP password.
   746      *
   746      *
   747      * @param  string $password
   747      * @param  string $password
   748      * @param  string $hashType
   748      * @param  string $hashType
   749      * @param  string $attribName
   749      * @param  string $attribName
   750      * @return Zend_Ldap_Node Provides a fluid interface
   750      * @return Zend_Ldap_Node Provides a fluent interface
   751      * @throws Zend_Ldap_Exception
   751      * @throws Zend_Ldap_Exception
   752      */
   752      */
   753     public function setPasswordAttribute($password, $hashType = Zend_Ldap_Attribute::PASSWORD_HASH_MD5,
   753     public function setPasswordAttribute($password, $hashType = Zend_Ldap_Attribute::PASSWORD_HASH_MD5,
   754         $attribName = 'userPassword')
   754         $attribName = 'userPassword')
   755     {
   755     {
   764      * This method deletes the attribute.
   764      * This method deletes the attribute.
   765      *
   765      *
   766      * This is an offline method.
   766      * This is an offline method.
   767      *
   767      *
   768      * @param  string $name
   768      * @param  string $name
   769      * @return Zend_Ldap_Node Provides a fluid interface
   769      * @return Zend_Ldap_Node Provides a fluent interface
   770      * @throws Zend_Ldap_Exception
   770      * @throws Zend_Ldap_Exception
   771      */
   771      */
   772     public function deleteAttribute($name)
   772     public function deleteAttribute($name)
   773     {
   773     {
   774         if ($this->existsAttribute($name, true)) {
   774         if ($this->existsAttribute($name, true)) {
   918      * Reload node attributes from LDAP.
   918      * Reload node attributes from LDAP.
   919      *
   919      *
   920      * This is an online method.
   920      * This is an online method.
   921      *
   921      *
   922      * @param  Zend_Ldap $ldap
   922      * @param  Zend_Ldap $ldap
   923      * @return Zend_Ldap_Node Provides a fluid interface
   923      * @return Zend_Ldap_Node Provides a fluent interface
   924      * @throws Zend_Ldap_Exception
   924      * @throws Zend_Ldap_Exception
   925      */
   925      */
   926     public function reload(Zend_Ldap $ldap = null)
   926     public function reload(Zend_Ldap $ldap = null)
   927     {
   927     {
   928         if ($ldap !== null) {
   928         if ($ldap !== null) {