aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/user_ldap/lib/access.php12
-rw-r--r--apps/user_ldap/lib/wizard.php5
-rw-r--r--apps/user_ldap/tests/user_ldap.php32
-rw-r--r--apps/user_ldap/user_ldap.php3
4 files changed, 16 insertions, 36 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index d89029abf17..0d51fc51143 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -1168,6 +1168,18 @@ class Access extends LDAPUtility implements user\IUserTools {
}
/**
+ * returns the filter used for counting users
+ */
+ public function getFilterForUserCount() {
+ $filter = $this->combineFilterWithAnd(array(
+ $this->connection->ldapUserFilter,
+ $this->connection->ldapUserDisplayName . '=*'
+ ));
+
+ return $filter;
+ }
+
+ /**
* @param string $name
* @param string $password
* @return bool
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index c5db4c66cc0..f373fabb69c 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -121,10 +121,7 @@ class Wizard extends LDAPUtility {
*/
public function countUsers() {
$this->detectUserDisplayNameAttribute();
- $filter = $this->access->combineFilterWithAnd(array(
- $this->configuration->ldapUserFilter,
- $this->configuration->ldapUserDisplayName . '=*'
- ));
+ $filter = $this->access->getFilterForUserCount();
$usersTotal = $this->countEntries($filter, 'users');
$usersTotal = ($usersTotal !== false) ? $usersTotal : 0;
diff --git a/apps/user_ldap/tests/user_ldap.php b/apps/user_ldap/tests/user_ldap.php
index c89edc33fa9..d975fd56c51 100644
--- a/apps/user_ldap/tests/user_ldap.php
+++ b/apps/user_ldap/tests/user_ldap.php
@@ -550,23 +550,9 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
public function testCountUsers() {
$access = $this->getAccessMock();
- $access->connection->expects($this->once())
- ->method('__get')
- ->will($this->returnCallback(function($name) {
- if($name === 'ldapLoginFilter') {
- return 'uid=%uid';
- }
- return null;
- }));
-
$access->expects($this->once())
->method('countUsers')
- ->will($this->returnCallback(function($filter, $a, $b, $c) {
- if($filter !== 'uid=*') {
- return false;
- }
- return 5;
- }));
+ ->will($this->returnValue(5));
$backend = new UserLDAP($access);
@@ -577,23 +563,9 @@ class Test_User_Ldap_Direct extends \PHPUnit_Framework_TestCase {
public function testCountUsersFailing() {
$access = $this->getAccessMock();
- $access->connection->expects($this->once())
- ->method('__get')
- ->will($this->returnCallback(function($name) {
- if($name === 'ldapLoginFilter') {
- return 'invalidFilter';
- }
- return null;
- }));
-
$access->expects($this->once())
->method('countUsers')
- ->will($this->returnCallback(function($filter, $a, $b, $c) {
- if($filter !== 'uid=*') {
- return false;
- }
- return 5;
- }));
+ ->will($this->returnValue(false));
$backend = new UserLDAP($access);
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
index 6e244311d4a..c2f87ebeb22 100644
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -290,8 +290,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface {
* @return int|bool
*/
public function countUsers() {
- $filter = \OCP\Util::mb_str_replace(
- '%uid', '*', $this->access->connection->ldapLoginFilter, 'UTF-8');
+ $filter = $this->access->getFilterForUserCount();
$entries = $this->access->countUsers($filter);
return $entries;
}