From 353a8e442f895500b8f324c2dc4afd389ac52425 Mon Sep 17 00:00:00 2001
From: Arthur Schiwon <blizzz@owncloud.com>
Date: Thu, 1 Oct 2015 00:30:05 +0200
Subject: fix possible infinite loop when reading groups in the wizard

---
 apps/user_ldap/lib/access.php | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

(limited to 'apps/user_ldap/lib/access.php')

diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 2a605a2a0f0..e5bb4fc10f6 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -1466,6 +1466,30 @@ class Access extends LDAPUtility implements user\IUserTools {
 		return $cookie;
 	}
 
+	/**
+	 * checks whether an LDAP paged search operation has more pages that can be
+	 * retrieved, typically when offset and limit are provided.
+	 *
+	 * Be very careful to use it: the last cookie value, which is inspected, can
+	 * be reset by other operations. Best, call it immediately after a search(),
+	 * searchUsers() or searchGroups() call. count-methods are probably safe as
+	 * well. Don't rely on it with any fetchList-method.
+	 * @return bool
+	 */
+	public function hasMoreResults() {
+		if(!$this->connection->hasPagedResultSupport) {
+			return false;
+		}
+
+		if(empty($this->lastCookie) && $this->lastCookie !== '0') {
+			// as in RFC 2696, when all results are returned, the cookie will
+			// be empty.
+			return false;
+		}
+
+		return true;
+	}
+
 	/**
 	 * set a cookie for LDAP paged search run
 	 * @param string $base a string with the base DN for the search
-- 
cgit v1.2.3