From 33ec26f6d62b7558bac3665b90315c950e5cb7b0 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 6 Feb 2013 14:24:00 +0100 Subject: [PATCH 1/4] LDAP: info string improved --- apps/user_ldap/templates/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/templates/settings.php b/apps/user_ldap/templates/settings.php index eb3840a611..c6f1834e01 100644 --- a/apps/user_ldap/templates/settings.php +++ b/apps/user_ldap/templates/settings.php @@ -35,7 +35,7 @@

-

+

>


t('Not recommended, use for testing only.');?>

From e122fdbcb63cc4e36982dc23bd2a38c904417447 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 6 Feb 2013 14:30:17 +0100 Subject: [PATCH 2/4] LDAP: when ldaps and tls are configured, disable the latter one - they do not work together. ldaps already creates a secure connection. --- apps/user_ldap/lib/connection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index acc33e047c..38b2b131e5 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -409,6 +409,11 @@ class Connection { $this->config[$key] = array(); } } + if((strpos($this->config['ldapHost'], 'ldaps') === 0) + && $this->config['ldapTLS']) { + $this->config['ldapTLS'] = false; + \OCP\Util::writeLog('user_ldap', 'LDAPS (already using secure connection) and TLS do not work together. Switched of TLS.', \OCP\Util::INFO); + } From 781d247b39930e54d4e40c2c197c80367827b852 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 6 Feb 2013 14:32:00 +0100 Subject: [PATCH 3/4] LDAP: better detect timeouts. do not try to reconnect. do not try to bind when connection failed. makes ownCloud more responsive, esp. with multiple server connections configured --- apps/user_ldap/lib/connection.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 38b2b131e5..9b440da4f9 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -528,7 +528,7 @@ class Connection { if(!$this->config['ldapOverrideMainServer'] && !$this->getFromCache('overrideMainServer')) { $this->doConnect($this->config['ldapHost'], $this->config['ldapPort']); $bindStatus = $this->bind(); - $error = ldap_errno($this->ldapConnectionRes); + $error = is_resource($this->ldapConnectionRes) ? ldap_errno($this->ldapConnectionRes) : -1; } else { $bindStatus = false; $error = null; @@ -552,6 +552,9 @@ class Connection { } private function doConnect($host, $port) { + if(empty($host)) { + return false; + } $this->ldapConnectionRes = ldap_connect($host, $port); if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) { if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) { @@ -569,9 +572,13 @@ class Connection { if(!$this->config['ldapConfigurationActive']) { return false; } - $ldapLogin = @ldap_bind($this->getConnectionResource(), $this->config['ldapAgentName'], $this->config['ldapAgentPassword']); + $cr = $this->getConnectionResource(); + if(!is_resource($cr)) { + return false; + } + $ldapLogin = @ldap_bind($cr, $this->config['ldapAgentName'], $this->config['ldapAgentPassword']); if(!$ldapLogin) { - \OCP\Util::writeLog('user_ldap', 'Bind failed: ' . ldap_errno($this->ldapConnectionRes) . ': ' . ldap_error($this->ldapConnectionRes), \OCP\Util::ERROR); + \OCP\Util::writeLog('user_ldap', 'Bind failed: ' . ldap_errno($cr) . ': ' . ldap_error($cr), \OCP\Util::ERROR); $this->ldapConnectionRes = null; return false; } From 15e383fd013ab44f6f0b3edcbbde206dadb33219 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Thu, 7 Feb 2013 16:05:45 +0100 Subject: [PATCH 4/4] Typo --- apps/user_ldap/lib/connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 9b440da4f9..f92779b1ca 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -412,7 +412,7 @@ class Connection { if((strpos($this->config['ldapHost'], 'ldaps') === 0) && $this->config['ldapTLS']) { $this->config['ldapTLS'] = false; - \OCP\Util::writeLog('user_ldap', 'LDAPS (already using secure connection) and TLS do not work together. Switched of TLS.', \OCP\Util::INFO); + \OCP\Util::writeLog('user_ldap', 'LDAPS (already using secure connection) and TLS do not work together. Switched off TLS.', \OCP\Util::INFO); }