From 4976f2e0d363e980a90745bb2e2cb93d5dd2f5cb Mon Sep 17 00:00:00 2001
From: Arthur Schiwon <blizzz@owncloud.com>
Date: Mon, 3 Jun 2013 23:07:32 +0200
Subject: [PATCH] LDAP: append port when URL is passed in LDAP Host
 configuration, fixes #2600

---
 apps/user_ldap/lib/connection.php | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 409f375879..31150a5bec 100644
--- a/apps/user_ldap/lib/connection.php
+++ b/apps/user_ldap/lib/connection.php
@@ -621,6 +621,10 @@ class Connection {
 		if(empty($host)) {
 			return false;
 		}
+		if(strpos($host, '://') !== false) {
+			//ldap_connect ignores port paramater when URLs are passed
+			$host .= ':' . $port;
+		}
 		$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)) {
-- 
GitLab