sources/ldap: create event when user integrity error occurs
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
5a5a32ff83
commit
98318953cd
|
@ -7,6 +7,7 @@ from django.db.utils import IntegrityError
|
||||||
from pytz import UTC
|
from pytz import UTC
|
||||||
|
|
||||||
from authentik.core.models import User
|
from authentik.core.models import User
|
||||||
|
from authentik.events.models import Event, EventAction
|
||||||
from authentik.sources.ldap.sync.base import LDAP_UNIQUENESS, BaseLDAPSynchronizer
|
from authentik.sources.ldap.sync.base import LDAP_UNIQUENESS, BaseLDAPSynchronizer
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,13 +49,16 @@ class UserLDAPSynchronizer(BaseLDAPSynchronizer):
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
except IntegrityError as exc:
|
except IntegrityError as exc:
|
||||||
self._logger.warning("Failed to create user", exc=exc)
|
Event.new(
|
||||||
self._logger.warning(
|
EventAction.CONFIGURATION_ERROR,
|
||||||
(
|
message=(
|
||||||
|
f"Failed to create user: {str(exc)} "
|
||||||
"To merge new user with existing user, set the user's "
|
"To merge new user with existing user, set the user's "
|
||||||
f"Attribute '{LDAP_UNIQUENESS}' to '{uniq}'"
|
f"Attribute '{LDAP_UNIQUENESS}' to '{uniq}'"
|
||||||
)
|
),
|
||||||
)
|
source=self._source,
|
||||||
|
dn=user_dn,
|
||||||
|
).save()
|
||||||
else:
|
else:
|
||||||
self._logger.debug(
|
self._logger.debug(
|
||||||
"Synced User", user=ak_user.username, created=created
|
"Synced User", user=ak_user.username, created=created
|
||||||
|
|
Reference in New Issue