diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php
index 409f3758792ebe147642d0528e9429774b75aa07..31150a5bec57d2c9575e4f3e7af68d82213a6f24 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)) {