web/lib/Zend/Ldap/Collection/Iterator/Default.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    12  * obtain it through the world-wide-web, please send an email
    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  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @version    $Id: Default.php 20096 2010-01-06 02:05:09Z bkarwin $
    19  * @version    $Id: Default.php 24612 2012-01-21 14:42:30Z sgehrig $
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * Zend_Ldap_Collection_Iterator_Default is the default collection iterator implementation
    23  * Zend_Ldap_Collection_Iterator_Default is the default collection iterator implementation
    24  * using ext/ldap
    24  * using ext/ldap
    25  *
    25  *
    26  * @category   Zend
    26  * @category   Zend
    27  * @package    Zend_Ldap
    27  * @package    Zend_Ldap
    28  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    28  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    29  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    30  */
    30  */
    31 class Zend_Ldap_Collection_Iterator_Default implements Iterator, Countable
    31 class Zend_Ldap_Collection_Iterator_Default implements Iterator, Countable
    32 {
    32 {
    33     const ATTRIBUTE_TO_LOWER  = 1;
    33     const ATTRIBUTE_TO_LOWER  = 1;
   258      *
   258      *
   259      * @throws Zend_Ldap_Exception
   259      * @throws Zend_Ldap_Exception
   260      */
   260      */
   261     public function next()
   261     public function next()
   262     {
   262     {
   263         if (is_resource($this->_current)) {
   263         if (is_resource($this->_current) && $this->_itemCount > 0) {
   264             $this->_current = @ldap_next_entry($this->_ldap->getResource(), $this->_current);
   264             $this->_current = @ldap_next_entry($this->_ldap->getResource(), $this->_current);
   265             /** @see Zend_Ldap_Exception */
   265             /** @see Zend_Ldap_Exception */
   266             require_once 'Zend/Ldap/Exception.php';
   266             require_once 'Zend/Ldap/Exception.php';
   267             if ($this->_current === false) {
   267             if ($this->_current === false) {
   268                 $msg = $this->_ldap->getLastError($code);
   268                 $msg = $this->_ldap->getLastError($code);
   271                     return;
   271                     return;
   272                 } else if ($code > Zend_Ldap_Exception::LDAP_SUCCESS) {
   272                 } else if ($code > Zend_Ldap_Exception::LDAP_SUCCESS) {
   273                      throw new Zend_Ldap_Exception($this->_ldap, 'getting next entry (' . $msg . ')');
   273                      throw new Zend_Ldap_Exception($this->_ldap, 'getting next entry (' . $msg . ')');
   274                 }
   274                 }
   275             }
   275             }
       
   276         } else {
       
   277             $this->_current = false;
   276         }
   278         }
   277     }
   279     }
   278 
   280 
   279     /**
   281     /**
   280      * Rewind the Iterator to the first result item
   282      * Rewind the Iterator to the first result item