/** * Paginates the current LDAP query. * * @param int $perPage * @param int $currentPage * @param bool $isCritical * * @return Paginator|bool */ public function paginate($perPage = 50, $currentPage = 0, $isCritical = true) { // Set the current query to paginated $this->paginated = true; // Stores all LDAP entries in a page array $pages = []; $cookie = ''; do { $this->connection->controlPagedResult($perPage, $isCritical, $cookie); $results = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects()); if ($results) { $this->connection->controlPagedResultResponse($results, $cookie); // We'll collect the results into the pages array. $pages[] = $results; } } while ($cookie !== null && !empty($cookie)); if (count($pages) > 0) { return $this->newProcessor()->processPaginated($pages, $perPage, $currentPage); } return false; }