diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php index defed4e35a78..9bd9cef35ce3 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php @@ -159,7 +159,11 @@ private function connect() } } - $this->connection = ldap_connect($this->config['connection_string']); + if (false === $connection = ldap_connect($this->config['connection_string'])) { + throw new LdapException('Invalid connection string: '.$this->config['connection_string']); + } else { + $this->connection = $connection; + } foreach ($this->config['options'] as $name => $value) { if (!\in_array(ConnectionOptions::getOption($name), self::PRECONNECT_OPTIONS, true)) { @@ -167,10 +171,6 @@ private function connect() } } - if (false === $this->connection) { - throw new LdapException('Could not connect to Ldap server: '.ldap_error($this->connection)); - } - if ('tls' === $this->config['encryption'] && false === @ldap_start_tls($this->connection)) { throw new LdapException('Could not initiate TLS connection: '.ldap_error($this->connection)); }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: