From f608e4586cde9c8d3bac5725267bdbef24bcc7ee Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Sun, 15 May 2022 09:25:28 -0700 Subject: [PATCH] Only set manager ID when the lookup succeeds. --- app/Console/Commands/LdapSync.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 2df54632e5..052a99932b 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -213,12 +213,14 @@ class LdapSync extends Command $user->country = $item['country']; $user->department_id = $department->id; - if($item['manager']!= null) { + if($item['manager'] != null) { //Captures only the Canonical Name $item['manager'] = ltrim($item['manager'], "CN="); $item['manager'] = substr($item['manager'],0, strpos($item['manager'], ',')); $ldap_manager = User::where('username', $item['manager'])->first(); - $user->manager_id = $ldap_manager->id; + if ( $ldap_manager && isset($ldap_manager->id) ) { + $user->manager_id = $ldap_manager->id; + } }