File tree 2 files changed +23
-1
lines changed
src/Symfony/Component/Ldap/Adapter/ExtLdap
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -147,12 +147,21 @@ private function connect()
147
147
return ;
148
148
}
149
149
150
+ foreach ($ this ->config ['options ' ] as $ name => $ value ) {
151
+ if (ConnectionOptions::isPreconnectOption ($ name )) {
152
+ $ this ->setOption ($ name , $ value );
153
+ }
154
+ }
155
+
150
156
$ this ->connection = ldap_connect ($ this ->config ['connection_string ' ]);
151
157
152
158
foreach ($ this ->config ['options ' ] as $ name => $ value ) {
153
- $ this ->setOption ($ name , $ value );
159
+ if (!ConnectionOptions::isPreconnectOption ($ name )) {
160
+ $ this ->setOption ($ name , $ value );
161
+ }
154
162
}
155
163
164
+
156
165
if (false === $ this ->connection ) {
157
166
throw new LdapException ('Could not connect to Ldap server: ' .ldap_error ($ this ->connection ));
158
167
}
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ final class ConnectionOptions
40
40
public const DEBUG_LEVEL = 0x5001 ;
41
41
public const TIMEOUT = 0x5002 ;
42
42
public const NETWORK_TIMEOUT = 0x5005 ;
43
+ public const X_TLS_CACERTFILE = 0x6002 ;
43
44
public const X_TLS_CACERTDIR = 0x6003 ;
44
45
public const X_TLS_CERTFILE = 0x6004 ;
45
46
public const X_TLS_CRL_ALL = 0x02 ;
@@ -62,6 +63,13 @@ final class ConnectionOptions
62
63
public const X_KEEPALIVE_PROBES = 0x6301 ;
63
64
public const X_KEEPALIVE_INTERVAL = 0x6302 ;
64
65
66
+ private const PRECONNECT_OPTIONS = [
67
+ self ::DEBUG_LEVEL ,
68
+ self ::X_TLS_CACERTDIR ,
69
+ self ::X_TLS_CACERTFILE ,
70
+ self ::X_TLS_REQUIRE_CERT ,
71
+ ];
72
+
65
73
public static function getOptionName (string $ name ): string
66
74
{
67
75
return sprintf ('%s::%s ' , self ::class, strtoupper ($ name ));
@@ -89,4 +97,9 @@ public static function isOption(string $name): bool
89
97
{
90
98
return \defined (self ::getOptionName ($ name ));
91
99
}
100
+
101
+ public static function isPreconnectOption (string $ name ): bool
102
+ {
103
+ return \in_array (self ::getOption ($ name ), self ::PRECONNECT_OPTIONS , true );
104
+ }
92
105
}
You can’t perform that action at this time.
0 commit comments