allow to specify a port with tls too: "tls://host[:port]/" or "ldaps://host[:port]/" or "ldap://host[:port]/" or just "host"

This commit is contained in:
Ralf Becker 2012-03-01 13:08:58 +00:00
parent 90379afe16
commit b2a6e59b09

View File

@ -16,8 +16,8 @@
* LDAP connection handling * LDAP connection handling
* *
* Please note for SSL or TLS connections hostname has to be: * Please note for SSL or TLS connections hostname has to be:
* - SSL: "ldaps://host" * - SSL: "ldaps://host[:port]/"
* - TLS: "tls://host" * - TLS: "tls://host[:port]/"
* Both require certificats installed on the webserver, otherwise the connection will fail! * Both require certificats installed on the webserver, otherwise the connection will fail!
*/ */
class ldap class ldap
@ -112,10 +112,11 @@ class ldap
if (($use_tls = substr($host,0,6) == 'tls://')) if (($use_tls = substr($host,0,6) == 'tls://'))
{ {
$port = parse_url($host,PHP_URL_PORT);
$host = parse_url($host,PHP_URL_HOST); $host = parse_url($host,PHP_URL_HOST);
} }
// connects to ldap server // connects to ldap server
if(!$this->ds = ldap_connect($host)) if(!$this->ds = ldap_connect($host, $port))
{ {
/* log does not exist in setup(, yet) */ /* log does not exist in setup(, yet) */
if(isset($GLOBALS['egw']->log)) if(isset($GLOBALS['egw']->log))