/** * Rewind the Iterator to the first result item * Implements Iterator * * @throws \Zend\Ldap\Exception */ public function rewind() { if (is_resource($this->_resultId)) { $this->_current = @ldap_first_entry($this->_ldap->getResource(), $this->_resultId); if ($this->_current === false && $this->_ldap->getLastErrorCode() > Ldap\Exception::LDAP_SUCCESS) { throw new Ldap\Exception($this->_ldap, 'getting first entry'); } } }
/** * Rewind the Iterator to the first result item * Implements Iterator * * * @throws \Zend\Ldap\Exception\LdapException */ public function rewind() { if (is_resource($this->resultId)) { ErrorHandler::start(); $this->current = ldap_first_entry($this->ldap->getResource(), $this->resultId); ErrorHandler::stop(); if ($this->current === false && $this->ldap->getLastErrorCode() > Exception\LdapException::LDAP_SUCCESS) { throw new Exception\LdapException($this->ldap, 'getting first entry'); } } }
public function testGetErrorCode() { $ldap = new Ldap\Ldap($this->options); try { // Connect doesn't actually try to connect until bind is called // but if we get 'Invalid credentials' then we know the connect // succeeded. $ldap->connect()->bind('CN=ignored,DC=example,DC=com', 'ignored'); $this->fail('Expected exception for invalid username'); } catch (Exception\LdapException $zle) { $this->assertContains('Invalid credentials', $zle->getMessage()); $this->assertEquals(0x31, $zle->getCode()); $this->assertEquals(0x0, $ldap->getLastErrorCode()); } }