summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-03-01 14:35:41 +0100
committerVincent Petry <pvince81@owncloud.com>2016-03-01 14:35:41 +0100
commitb558fc4d02eef882b46a79dc30f94e6d564bbd5d (patch)
treee61a7047756e0d6fb9fb08fedfa8ace4f397ae21
parent848fa0808039a05fc0c7ec388fd2f81115dc8221 (diff)
parentcb54370ea50b8a092ad080ee931c5cdface5d506 (diff)
downloadnextcloud-server-b558fc4d02eef882b46a79dc30f94e6d564bbd5d.tar.gz
nextcloud-server-b558fc4d02eef882b46a79dc30f94e6d564bbd5d.zip
Merge pull request #21634 from owncloud/backport-17924-stable8
[backport] [stable8] always use an LDAP URL when connecting to LDAP
-rw-r--r--apps/user_ldap/lib/connection.php4
-rw-r--r--apps/user_ldap/lib/ldap.php9
-rw-r--r--apps/user_ldap/lib/wizard.php17
3 files changed, 12 insertions, 18 deletions
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 2e9e6e05efd..dac8db3b524 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -569,10 +569,6 @@ class Connection extends LDAPUtility {
if(empty($host)) {
return false;
}
- if(strpos($host, '://') !== false) {
- //ldap_connect ignores port parameter when URLs are passed
- $host .= ':' . $port;
- }
$this->ldapConnectionRes = $this->ldap->connect($host, $port);
if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
if($this->ldap->setOption($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
diff --git a/apps/user_ldap/lib/ldap.php b/apps/user_ldap/lib/ldap.php
index 9d5cf4fee0a..63ec668dc03 100644
--- a/apps/user_ldap/lib/ldap.php
+++ b/apps/user_ldap/lib/ldap.php
@@ -45,7 +45,14 @@ class LDAP implements ILDAPWrapper {
* @return mixed
*/
public function connect($host, $port) {
- return $this->invokeLDAPMethod('connect', $host, $port);
+ if(strpos($host, '://') === false) {
+ $host = 'ldap://' . $host;
+ }
+ if(strpos($host, ':', strpos($host, '://') + 1) === false) {
+ //ldap_connect ignores port parameter when URLs are passed
+ $host .= ':' . $port;
+ }
+ return $this->invokeLDAPMethod('connect', $host);
}
/**
diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php
index 71d0071fc95..2397bef2191 100644
--- a/apps/user_ldap/lib/wizard.php
+++ b/apps/user_ldap/lib/wizard.php
@@ -995,13 +995,6 @@ class Wizard extends LDAPUtility {
if(!$hostInfo) {
throw new \Exception($this->l->t('Invalid Host'));
}
- if(isset($hostInfo['scheme'])) {
- if(isset($hostInfo['port'])) {
- //problem
- } else {
- $host .= ':' . $port;
- }
- }
\OCP\Util::writeLog('user_ldap', 'Wiz: Attempting to connect ', \OCP\Util::DEBUG);
$cr = $this->ldap->connect($host, $port);
if(!is_resource($cr)) {
@@ -1250,12 +1243,10 @@ class Wizard extends LDAPUtility {
return $this->cr;
}
- $host = $this->configuration->ldapHost;
- if(strpos($host, '://') !== false) {
- //ldap_connect ignores port parameter when URLs are passed
- $host .= ':' . $this->configuration->ldapPort;
- }
- $cr = $this->ldap->connect($host, $this->configuration->ldapPort);
+ $cr = $this->ldap->connect(
+ $this->configuration->ldapHost,
+ $this->configuration->ldapPort
+ );
$this->ldap->setOption($cr, LDAP_OPT_PROTOCOL_VERSION, 3);
$this->ldap->setOption($cr, LDAP_OPT_REFERRALS, 0);