7
7
use Adldap \Auth \BindException ;
8
8
use Adldap \Connections \Provider ;
9
9
use Adldap \Connections \ConnectionInterface ;
10
+ use Adldap \Connections \ConnectionException ;
10
11
use Illuminate \Container \Container ;
11
12
use Illuminate \Support \Facades \Config ;
12
13
use Illuminate \Support \ServiceProvider ;
@@ -95,25 +96,29 @@ protected function addProviders(Adldap $adldap, array $connections = [])
95
96
{
96
97
// Go through each connection and construct a Provider.
97
98
foreach ($ connections as $ name => $ config ) {
98
- // Create a new provider.
99
- $ provider = $ this ->newProvider (
100
- $ config ['settings ' ],
101
- new $ config ['connection ' ]
102
- );
103
-
104
- if ($ this ->shouldAutoConnect ($ config )) {
105
- try {
106
- $ provider ->connect ();
107
- } catch (BindException $ e ) {
108
- // We'll catch and log bind exceptions so
109
- // any connection issues fail gracefully
110
- // in our application.
111
- logger ()->error ($ e );
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
+ }
112
115
}
113
- }
114
116
115
- // Add the provider to the Adldap container.
116
- $ adldap ->addProvider ($ provider , $ name );
117
+ // Add the provider to the Adldap container.
118
+ $ adldap ->addProvider ($ provider , $ name );
119
+ } catch (ConnectionException $ e ) {
120
+ logger ()->error ($ e );
121
+ }
117
122
}
118
123
119
124
return $ adldap ;
@@ -132,9 +137,11 @@ protected function newAdldap()
132
137
/**
133
138
* Returns a new Provider instance.
134
139
*
135
- * @param array $configuration
140
+ * @param array $configuration
136
141
* @param ConnectionInterface|null $connection
137
142
*
143
+ * @throws ConnectionException If starting TLS fails.
144
+ *
138
145
* @return Provider
139
146
*/
140
147
protected function newProvider ($ configuration = [], ConnectionInterface $ connection = null )
0 commit comments