From b889e218dc623cb73d04abba43adcef608ece9bd Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 28 Aug 2023 14:06:33 -0500 Subject: [PATCH] LDAP Authorizer hand count entry (#15259) --- LibreNMS/Authentication/LdapAuthorizer.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/LibreNMS/Authentication/LdapAuthorizer.php b/LibreNMS/Authentication/LdapAuthorizer.php index 3d4522484b..432d76aa53 100644 --- a/LibreNMS/Authentication/LdapAuthorizer.php +++ b/LibreNMS/Authentication/LdapAuthorizer.php @@ -128,14 +128,16 @@ class LdapAuthorizer extends AuthorizerBase $roles = []; // Collect all assigned roles foreach ($entries as $entry) { - $groupname = $entry['cn'][0]; + if (isset($entry['cn'][0])) { + $groupname = $entry['cn'][0]; - if (isset($groups[$groupname]['roles']) && is_array($groups[$groupname]['roles'])) { - $roles = array_merge($roles, $groups[$groupname]['roles']); - } elseif (isset($groups[$groupname]['level'])) { - $role = LegacyAuthLevel::tryFrom($groups[$groupname]['level'])?->getName(); - if ($role) { - $roles[] = $role; + if (isset($groups[$groupname]['roles']) && is_array($groups[$groupname]['roles'])) { + $roles = array_merge($roles, $groups[$groupname]['roles']); + } elseif (isset($groups[$groupname]['level'])) { + $role = LegacyAuthLevel::tryFrom($groups[$groupname]['level'])?->getName(); + if ($role) { + $roles[] = $role; + } } } }