sources/ldap: prevent key `users` from being set as this is an M2M relation

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-10-27 15:43:56 +02:00
parent 9e0daf2bcf
commit fa6324ab1d
1 changed files with 3 additions and 0 deletions

View File

@ -40,6 +40,9 @@ class GroupLDAPSynchronizer(BaseLDAPSynchronizer):
self._logger.debug("Creating group with attributes", **defaults) self._logger.debug("Creating group with attributes", **defaults)
if "name" not in defaults: if "name" not in defaults:
raise IntegrityError("Name was not set by propertymappings") raise IntegrityError("Name was not set by propertymappings")
# Special check for `users` field, as this is an M2M relation, and cannot be sync'd
if "users" in defaults:
del defaults["users"]
ak_group, created = Group.objects.update_or_create( ak_group, created = Group.objects.update_or_create(
**{ **{
f"attributes__{LDAP_UNIQUENESS}": uniq, f"attributes__{LDAP_UNIQUENESS}": uniq,