@@ -38,7 +38,7 @@ public function retrieveByToken($identifier, $token)
3838 public function retrieveByCredentials (array $ credentials )
3939 {
4040 // Get the search query for users only
41- $ query = Adldap:: users ()-> search ();
41+ $ query = $ this -> newAdldapUserQuery ();
4242
4343 // Get the username input attributes
4444 $ attributes = $ this ->getUsernameAttribute ();
@@ -164,7 +164,7 @@ protected function discoverAdldapFromModel($model)
164164
165165 $ key = key ($ attributes );
166166
167- $ query = Adldap:: users ()-> search ();
167+ $ query = $ this -> newAdldapUserQuery ();
168168
169169 $ query ->whereEquals ($ attributes [$ key ], $ model ->{$ key });
170170
@@ -194,6 +194,16 @@ protected function bindAdldapToModel(User $user, Authenticatable $model)
194194 return $ model ;
195195 }
196196
197+ /**
198+ * Returns a new Adldap user query.
199+ *
200+ * @return \Adldap\Query\Builder
201+ */
202+ protected function newAdldapUserQuery ()
203+ {
204+ return Adldap::users ()->select ($ this ->getSelectAttributes ())->search ();
205+ }
206+
197207 /**
198208 * Authenticates a user against Active Directory.
199209 *
@@ -248,4 +258,15 @@ protected function getSyncAttributes()
248258 {
249259 return Config::get ('adldap_auth.sync_attributes ' , ['name ' => ActiveDirectory::COMMON_NAME ]);
250260 }
261+
262+ /**
263+ * Retrieves the Aldldap select attributes when performing
264+ * queries for authentication and binding for users.
265+ *
266+ * @return array
267+ */
268+ protected function getSelectAttributes ()
269+ {
270+ return Config::get ('adldap_auth.select_attributes ' , []);
271+ }
251272}
0 commit comments