From 9c6fc31113236d498d1e8a313dd502dc917d2921 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 30 Aug 2023 12:33:13 -0500 Subject: [PATCH] Fix LDAP Authorization Authorizer (#15267) https://community.librenms.org/t/8-28-sudden-ldap-authentication-issues/22176/10 --- .../LdapAuthorizationAuthorizer.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/LibreNMS/Authentication/LdapAuthorizationAuthorizer.php b/LibreNMS/Authentication/LdapAuthorizationAuthorizer.php index 637835a864..5566d1d0f2 100644 --- a/LibreNMS/Authentication/LdapAuthorizationAuthorizer.php +++ b/LibreNMS/Authentication/LdapAuthorizationAuthorizer.php @@ -130,14 +130,16 @@ class LdapAuthorizationAuthorizer extends AuthorizerBase $authLdapGroups = Config::get('auth_ldap_groups'); // Collect all roles foreach ($entries as $entry) { - $groupname = $entry['cn'][0]; + if (isset($entry['cn'][0])) { + $groupname = $entry['cn'][0]; - if (isset($authLdapGroups[$groupname]['roles']) && is_array($authLdapGroups[$groupname]['roles'])) { - $roles = array_merge($roles, $authLdapGroups[$groupname]['roles']); - } elseif (isset($authLdapGroups[$groupname]['level'])) { - $role = LegacyAuthLevel::tryFrom($authLdapGroups[$groupname]['level'])?->getName(); - if ($role) { - $roles[] = $role; + if (isset($authLdapGroups[$groupname]['roles']) && is_array($authLdapGroups[$groupname]['roles'])) { + $roles = array_merge($roles, $authLdapGroups[$groupname]['roles']); + } elseif (isset($authLdapGroups[$groupname]['level'])) { + $role = LegacyAuthLevel::tryFrom($authLdapGroups[$groupname]['level'])?->getName(); + if ($role) { + $roles[] = $role; + } } } }