From 68a04c7a239671e422a177a3bd39bf253ab59a5a Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 27 Sep 2018 16:13:27 -0700 Subject: [PATCH] Fixed #4151 - Undefined index: samaccountname on LDAP import --- app/Console/Commands/LdapSync.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index bcbc6a7b51..5c6c512355 100755 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -128,15 +128,19 @@ class LdapSync extends Command $location_users = Ldap::findLdapUsers($ldap_loc["ldap_ou"]); $usernames = array(); for ($i = 0; $i < $location_users["count"]; $i++) { - $location_users[$i]["ldap_location_override"] = true; - $location_users[$i]["location_id"] = $ldap_loc["id"]; - $usernames[] = $location_users[$i][$ldap_result_username][0]; + if (array_key_exists($ldap_result_username, $location_users[$i])) { + $location_users[$i]["ldap_location_override"] = true; + $location_users[$i]["location_id"] = $ldap_loc["id"]; + $usernames[] = $location_users[$i][$ldap_result_username][0]; + } } // Delete located users from the general group. foreach ($results as $key => $generic_entry) { - if (in_array($generic_entry[$ldap_result_username][0], $usernames)) { - unset($results[$key]); + if ((is_array($generic_entry)) && (array_key_exists($ldap_result_username, $generic_entry))) { + if (in_array($generic_entry[$ldap_result_username][0], $usernames)) { + unset($results[$key]); + } } }