sources/ldap: only warn about missing groups when source is configured to sync groups

closes #4392

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens Langhammer 2023-01-09 17:17:48 +01:00
parent a42f2f7217
commit 9445354b31
No known key found for this signature in database
1 changed files with 5 additions and 4 deletions

View File

@ -77,10 +77,11 @@ class MembershipLDAPSynchronizer(BaseLDAPSynchronizer):
if group_uniq not in self.group_cache: if group_uniq not in self.group_cache:
groups = Group.objects.filter(**{f"attributes__{LDAP_UNIQUENESS}": group_uniq}) groups = Group.objects.filter(**{f"attributes__{LDAP_UNIQUENESS}": group_uniq})
if not groups.exists(): if not groups.exists():
self.message( if self._source.sync_groups:
f"Group does not exist in our DB yet, run sync_groups first: '{group_dn}'", self.message(
group=group_dn, f"Group does not exist in our DB yet, run sync_groups first: '{group_dn}'",
) group=group_dn,
)
return None return None
self.group_cache[group_uniq] = groups.first() self.group_cache[group_uniq] = groups.first()
return self.group_cache[group_uniq] return self.group_cache[group_uniq]