diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2015-07-28 12:14:05 +0200 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2015-12-05 00:09:15 +0100 |
commit | a32b002cff4ace48a06fe7f45be85cb64862fbbe (patch) | |
tree | 6052d6f075fac8a2cb56c77c810164bd9b218b7b /apps/user_ldap/lib | |
parent | e91eba4b5bd856cb1ef81996ace6d16c09f1bb01 (diff) | |
download | nextcloud-server-a32b002cff4ace48a06fe7f45be85cb64862fbbe.tar.gz nextcloud-server-a32b002cff4ace48a06fe7f45be85cb64862fbbe.zip |
always use an LDAP URL when connecting to LDAP
Diffstat (limited to 'apps/user_ldap/lib')
-rw-r--r-- | apps/user_ldap/lib/connection.php | 4 | ||||
-rw-r--r-- | apps/user_ldap/lib/ldap.php | 9 | ||||
-rw-r--r-- | apps/user_ldap/lib/wizard.php | 17 |
3 files changed, 12 insertions, 18 deletions
diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 3f3953bb28b..57dc060f38e 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -575,10 +575,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 4d45db2e155..e730bff82c3 100644 --- a/apps/user_ldap/lib/ldap.php +++ b/apps/user_ldap/lib/ldap.php @@ -48,7 +48,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 e53ff35cfd6..20926fb06a4 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -1035,13 +1035,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)) { @@ -1291,12 +1284,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); |