From 9a40e5e651b0ecf92dda8700aaff893381919ce8 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 14 Dec 2017 14:57:43 -0600 Subject: [PATCH] return an error from ldap_search (#4623) This will return the error from the ldap_search ran in Models/Ldap.php instead of throwing an exception. Users seem to commonly be getting an Exception because of invalid search filters. This will better inform them of that issue without requiring them to enable DEBUG. --- app/Console/Commands/LdapSync.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 6ebfe6219..bff3b7232 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -67,8 +67,17 @@ class LdapSync extends Command $summary = array(); - $results = Ldap::findLdapUsers(); - + try { + $results = Ldap::findLdapUsers(); + } catch (\Exception $e) { + if ($this->option('json_summary')) { + $json_summary = [ "error" => true, "error_message" => $e->getMessage(), "summary" => [] ]; + $this->info(json_encode($json_summary)); + } + LOG::error($e); + return []; + } + // Retrieve locations with a mapped OU, and sort them from the shallowest to deepest OU (see #3993) $ldap_ou_locations = Location::where('ldap_ou', '!=', '')->get()->toArray(); $ldap_ou_lengths = array();