8000 [Ldap] Fix LDAP connection options by buffcode · Pull Request #46325 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Ldap] Fix LDAP connection options #46325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2022
Merged
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ class Connection extends AbstractConnection
private const LDAP_INVALID_CREDENTIALS = 0x31;
private const LDAP_TIMEOUT = 0x55;
private const LDAP_ALREADY_EXISTS = 0x44;
private const PRECONNECT_OPTIONS = [
ConnectionOptions::DEBUG_LEVEL,
ConnectionOptions::X_TLS_CACERTDIR,
ConnectionOptions::X_TLS_CACERTFILE,
ConnectionOptions::X_TLS_REQUIRE_CERT,
];

/** @var bool */
private $bound = false;
Expand Down Expand Up @@ -147,10 +153,18 @@ private function connect()
return;
}

foreach ($this->config['options'] as $name => $value) {
if (\in_array(ConnectionOptions::getOption($name), self::PRECONNECT_OPTIONS, true)) {
$this->setOption($name, $value);
}
}

$this->connection = ldap_connect($this->config['connection_string']);

foreach ($this->config['options'] as $name => $value) {
$this->setOption($name, $value);
if (!\in_array(ConnectionOptions::getOption($name), self::PRECONNECT_OPTIONS, true)) {
$th A0B0 is->setOption($name, $value);
}
}

if (false === $this->connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class ConnectionOptions
public const DEBUG_LEVEL = 0x5001;
public const TIMEOUT = 0x5002;
public const NETWORK_TIMEOUT = 0x5005;
public const X_TLS_CACERTFILE = 0x6002;
public const X_TLS_CACERTDIR = 0x6003;
public const X_TLS_CERTFILE = 0x6004;
public const X_TLS_CRL_ALL = 0x02;
Expand Down
0