* [FIX] Related #540. Set the LDAP server port when it's set within the hostname. Thanks to @bitking for the feedback.

This commit is contained in:
nuxsmin
2017-04-14 13:54:18 +02:00
parent b8e18b4219
commit bbf88f3339
2 changed files with 19 additions and 3 deletions

View File

@@ -62,6 +62,10 @@ abstract class LdapBase implements LdapInterface, AuthInterface
* @var string
*/
protected $server;
/**
* @var int
*/
protected $serverPort;
/**
* @var string
*/
@@ -161,7 +165,7 @@ abstract class LdapBase implements LdapInterface, AuthInterface
@ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
}
$this->ldapHandler = @ldap_connect($this->server);
$this->ldapHandler = @ldap_connect($this->server, $this->serverPort);
// Conexión al servidor LDAP
if (!is_resource($this->ldapHandler)) {
@@ -320,6 +324,7 @@ abstract class LdapBase implements LdapInterface, AuthInterface
public function setServer($server)
{
$this->server = $server;
$this->serverPort = $this->getServerPort();
}
/**
@@ -437,6 +442,7 @@ abstract class LdapBase implements LdapInterface, AuthInterface
{
$this->searchBase = Config::getConfig()->getLdapBase();
$this->server = $this->pickServer();
$this->serverPort = $this->getServerPort();
$this->bindDn = Config::getConfig()->getLdapBindUser();
$this->bindPass = Config::getConfig()->getLdapBindPass();
$this->group = Config::getConfig()->getLdapGroup();
@@ -454,6 +460,16 @@ abstract class LdapBase implements LdapInterface, AuthInterface
return true;
}
/**
* Devolver el puerto del servidor si está establecido
*
* @return int
*/
protected function getServerPort()
{
return preg_match('/[\d\.]+:(\d+)/', $this->server, $port) ? $port[1] : 389;
}
/**
* Obtener el servidor de LDAP a utilizar
*

View File

@@ -407,8 +407,8 @@ class Util
*/
public static function getVersion($retBuild = false, $normalized = false)
{
$build = 17041401;
$version = [2, 1, 6];
$build = 17041402;
$version = [2, 1, 7];
if ($normalized === true) {
return [implode('', $version), $build];