From 8bb0cba949ca6fd4fe3d48b1cec0153ab1ae4817 Mon Sep 17 00:00:00 2001 From: kkthxbye <> Date: Thu, 25 Nov 2021 08:09:50 +0100 Subject: [PATCH] Fix #7751 - LDAP: Only get API user from ldap when FIND_GROUP_PERMS is enabled --- netbox/netbox/api/authentication.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/netbox/netbox/api/authentication.py b/netbox/netbox/api/authentication.py index 7f8bee318..5e177bfcb 100644 --- a/netbox/netbox/api/authentication.py +++ b/netbox/netbox/api/authentication.py @@ -29,10 +29,13 @@ class TokenAuthentication(authentication.TokenAuthentication): if settings.REMOTE_AUTH_BACKEND == 'netbox.authentication.LDAPBackend': from netbox.authentication import LDAPBackend ldap_backend = LDAPBackend() - user = ldap_backend.populate_user(token.user.username) - # If the user is found in the LDAP directory use it, if not fallback to the local user - if user: - return user, token + + # Load from LDAP if FIND_GROUP_PERMS is active + if ldap_backend.settings.FIND_GROUP_PERMS: + user = ldap_backend.populate_user(token.user.username) + # If the user is found in the LDAP directory use it, if not fallback to the local user + if user: + return user, token return token.user, token