Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Ldap] Do not run ldap_set_option on failed connection
  • Loading branch information
tatankat authored and nicolas-grekas committed Sep 28, 2022
commit 8f4f2b1e58a02b7ab229cc912d0a0d1a0f9d319f
10 changes: 5 additions & 5 deletions src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,18 @@ 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)) {
$this->setOption($name, $value);
}
}

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));
}
Expand Down