From d7483d129f20dc5c9e922d7c907fa2574804ed3d Mon Sep 17 00:00:00 2001 From: "Langhammer, Jens" Date: Sat, 12 Oct 2019 13:59:52 +0200 Subject: [PATCH] sources/ldap(minor): call set_unusable_password when creating new user --- passbook/sources/ldap/connector.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/passbook/sources/ldap/connector.py b/passbook/sources/ldap/connector.py index 0c09e2af2..9e2871be5 100644 --- a/passbook/sources/ldap/connector.py +++ b/passbook/sources/ldap/connector.py @@ -82,10 +82,13 @@ class Connector: attributes=ldap3.ALL_ATTRIBUTES) for user in users: attributes = user.get('attributes', {}) - _, created = User.objects.update_or_create( + user, created = User.objects.update_or_create( attributes__ldap_uniq=attributes.get(self._source.object_uniqueness_field, ''), defaults=self._build_object_properties(attributes), ) + if created: + user.set_unusable_password() + user.save() LOGGER.debug("Synced User", user=attributes.get('name', ''), created=created) def sync_membership(self):