|
|
@@ -25,6 +25,16 @@ class TokenAuthentication(authentication.TokenAuthentication):
|
|
|
if not token.user.is_active:
|
|
|
raise exceptions.AuthenticationFailed("User inactive")
|
|
|
|
|
|
+ # When LDAP authentication is active try to load user data from LDAP directory
|
|
|
+ if (settings.REMOTE_AUTH_ENABLED and
|
|
|
+ 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
|
|
|
+
|
|
|
return token.user, token
|
|
|
|
|
|
|