Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 0bfd446

Browse files
committed
Catch ConnectionException when attempting a bind
1 parent bfa56c5 commit 0bfd446

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

src/AdldapServiceProvider.php

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -88,37 +88,30 @@ public function provides()
8888
* @param Adldap $adldap
8989
* @param array $connections
9090
*
91-
* @throws \Adldap\Auth\BindException
92-
*
9391
* @return Adldap
9492
*/
9593
protected function addProviders(Adldap $adldap, array $connections = [])
9694
{
9795
// Go through each connection and construct a Provider.
9896
foreach ($connections as $name => $config) {
99-
try {
100-
// Create a new provider.
101-
$provider = $this->newProvider(
102-
$config['settings'],
103-
new $config['connection']
104-
);
105-
106-
if ($this->shouldAutoConnect($config)) {
107-
try {
108-
$provider->connect();
109-
} catch (BindException $e) {
110-
// We will catch and log bind exceptions so
111-
// any connection issues fail gracefully
112-
// in our application.
113-
logger()->error($e);
114-
}
97+
// Create a new provider.
98+
$provider = $this->newProvider(
99+
$config['settings'],
100+
new $config['connection']
101+
);
102+
103+
if ($this->shouldAutoConnect($config)) {
104+
try {
105+
$provider->connect();
106+
} catch (BindException $e) {
107+
logger()->error($e);
108+
} catch (ConnectionException $e) {
109+
logger()->error($e);
115110
}
116-
117-
// Add the provider to the Adldap container.
118-
$adldap->addProvider($provider, $name);
119-
} catch (ConnectionException $e) {
120-
logger()->error($e);
121111
}
112+
113+
// Add the provider to the Adldap container.
114+
$adldap->addProvider($provider, $name);
122115
}
123116

124117
return $adldap;
@@ -140,8 +133,6 @@ protected function newAdldap()
140133
* @param array $configuration
141134
* @param ConnectionInterface|null $connection
142135
*
143-
* @throws ConnectionException If starting TLS fails.
144-
*
145136
* @return Provider
146137
*/
147138
protected function newProvider($configuration = [], ConnectionInterface $connection = null)

0 commit comments

Comments
 (0)