diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-10-29 10:24:48 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-11-20 18:31:39 +0100 |
commit | f9b4f5f4e548715b06feec14236d68d330e865b2 (patch) | |
tree | d5eada57354a83e303130503e49f1f932cbd480b /apps/user_ldap/lib/wizard.php | |
parent | 71944a59a5279b34b57aa68c5b7ad0173e4a6793 (diff) | |
download | nextcloud-server-f9b4f5f4e548715b06feec14236d68d330e865b2.tar.gz nextcloud-server-f9b4f5f4e548715b06feec14236d68d330e865b2.zip |
to reassure that selected attributes still work, do not count all matching entries but limit it to 1 in order to make it faster
Diffstat (limited to 'apps/user_ldap/lib/wizard.php')
-rw-r--r-- | apps/user_ldap/lib/wizard.php | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 59911fe77d1..63b7e22ce8c 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -132,9 +132,10 @@ class Wizard extends LDAPUtility { /** * counts users with a specified attribute * @param string $attr + * @param bool $existsCheck * @return int|bool */ - public function countUsersWithAttribute($attr) { + public function countUsersWithAttribute($attr, $existsCheck = false) { if(!$this->checkRequirements(array('ldapHost', 'ldapPort', 'ldapBase', @@ -148,7 +149,9 @@ class Wizard extends LDAPUtility { $attr . '=*' )); - return $this->access->countUsers($filter); + $limit = ($existsCheck === false) ? null : 1; + + return $this->access->countUsers($filter, array('dn'), $limit); } /** @@ -169,7 +172,7 @@ class Wizard extends LDAPUtility { if($attr !== 'displayName' && !empty($attr)) { // most likely not the default value with upper case N, // verify it still produces a result - $count = intval($this->countUsersWithAttribute($attr)); + $count = intval($this->countUsersWithAttribute($attr, true)); if($count > 0) { //no change, but we sent it back to make sure the user interface //is still correct, even if the ajax call was cancelled inbetween @@ -181,7 +184,7 @@ class Wizard extends LDAPUtility { // first attribute that has at least one result wins $displayNameAttrs = array('displayname', 'cn'); foreach ($displayNameAttrs as $attr) { - $count = intval($this->countUsersWithAttribute($attr)); + $count = intval($this->countUsersWithAttribute($attr, true)); if($count > 0) { $this->applyFind('ldap_display_name', $attr); @@ -209,7 +212,7 @@ class Wizard extends LDAPUtility { $attr = $this->configuration->ldapEmailAttribute; if(!empty($attr)) { - $count = intval($this->countUsersWithAttribute($attr)); + $count = intval($this->countUsersWithAttribute($attr, true)); if($count > 0) { return false; } |