From 608fe55889520be247bf13b1b391260c0e989b9d Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 4 Feb 2014 17:56:53 +0100 Subject: [PATCH 1/5] LDAP: extend LDAP wrapper search method for sizelimit, improves performance in wizard --- apps/user_ldap/lib/ildapwrapper.php | 4 +++- apps/user_ldap/lib/ldap.php | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/user_ldap/lib/ildapwrapper.php b/apps/user_ldap/lib/ildapwrapper.php index 20587cba7db..e60cf5ec63f 100644 --- a/apps/user_ldap/lib/ildapwrapper.php +++ b/apps/user_ldap/lib/ildapwrapper.php @@ -145,9 +145,11 @@ interface ILDAPWrapper { * @param $baseDN The DN of the entry to read from * @param $filter An LDAP filter * @param $attr array of the attributes to read + * @param $attrsonly optional, 1 if only attribute types shall be returned + * @param $limit optional, limits the result entries * @return an LDAP search result resource, false on error */ - public function search($link, $baseDN, $filter, $attr); + public function search($link, $baseDN, $filter, $attr, $attrsonly = 0, $limit = 0); /** * @brief Sets the value of the specified option to be $value diff --git a/apps/user_ldap/lib/ldap.php b/apps/user_ldap/lib/ldap.php index dda8533c41f..a99c6480121 100644 --- a/apps/user_ldap/lib/ldap.php +++ b/apps/user_ldap/lib/ldap.php @@ -85,9 +85,9 @@ class LDAP implements ILDAPWrapper { return $this->invokeLDAPMethod('read', $link, $baseDN, $filter, $attr); } - public function search($link, $baseDN, $filter, $attr) { - return $this->invokeLDAPMethod('search', $link, $baseDN, - $filter, $attr); + public function search($link, $baseDN, $filter, $attr, $attrsonly = 0, $limit = 0) { + return $this->invokeLDAPMethod('search', $link, $baseDN, $filter, + $attr, $attrsonly, $limit); } public function setOption($link, $option, $value) { From 60b75b25f83fecceb72c5d28e3c05dac5d074457 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 4 Feb 2014 19:37:40 +0100 Subject: [PATCH 2/5] throw an info message, when base dn test failed --- apps/user_ldap/lib/wizard.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index b70ede8599c..30ce455274b 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -567,6 +567,10 @@ class Wizard extends LDAPUtility { //get a result set > 0 on a proper base $rr = $this->ldap->search($cr, $base, 'objectClass=*', array('dn'), 0, 1); if(!$this->ldap->isResource($rr)) { + $errorNo = $this->ldap->errno($cr); + $errorMsg = $this->ldap->error($cr); + \OCP\Util::writeLog('user_ldap', 'Wiz: Could not search base '.$base. + ' Error '.$errorNo.': '.$errorMsg, \OCP\Util::INFO); return false; } $entries = $this->ldap->countEntries($cr, $rr); From acebc3f41ebc1ed0bb62ec8abc053a969dae0ed3 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 5 Feb 2014 10:29:09 +0100 Subject: [PATCH 3/5] Wizard: disable LDAP referrals, fixes #6670 --- apps/user_ldap/lib/wizard.php | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 30ce455274b..00623b74fb1 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -1014,6 +1014,7 @@ class Wizard extends LDAPUtility { $this->configuration->ldapPort); $this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3); + $this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0); $this->ldap->setOption($cr, LDAP_OPT_NETWORK_TIMEOUT, self::LDAP_NW_TIMEOUT); if($this->configuration->ldapTLS === 1) { $this->ldap->startTls($cr); From 2801edc451205c96df719095c666aafb2606cb54 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 5 Feb 2014 10:30:56 +0100 Subject: [PATCH 4/5] Wizard: enable base DN for editing, if not base DN could have been detected. Also part of fix for #6670 --- apps/user_ldap/js/settings.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/user_ldap/js/settings.js b/apps/user_ldap/js/settings.js index acf88ef58a4..792638f2b58 100644 --- a/apps/user_ldap/js/settings.js +++ b/apps/user_ldap/js/settings.js @@ -240,6 +240,7 @@ var LdapWizard = { LdapWizard.hideSpinner('#ldap_base'); LdapWizard.showInfoBox('Please specify a Base DN'); LdapWizard.showInfoBox('Could not determine Base DN'); + $('#ldap_base').prop('disabled', false); } ); } From a967acee4c0983c8e81d227d9817fd92eb9bca1a Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 5 Feb 2014 10:33:44 +0100 Subject: [PATCH 5/5] Rephrase and clarify log message --- apps/user_ldap/lib/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 72f9c740921..b619f62f296 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -729,7 +729,7 @@ class Access extends LDAPUtility { } } else { if(!is_null($limit)) { - \OCP\Util::writeLog('user_ldap', 'Paged search failed :(', \OCP\Util::INFO); + \OCP\Util::writeLog('user_ldap', 'Paged search was not available', \OCP\Util::INFO); } } }