Commit 27c2b964 authored by Benjamin Fischer's avatar Benjamin Fischer

LDAPExport: use a "restartable" ldap connection & log membership changes

parent af5620da
......@@ -38,7 +38,7 @@ class LDAPExport(object):
if not url:
return
self.connection = ldap3.Connection(url, user, password, auto_bind=True, raise_exceptions=True)
self.connection = ldap3.Connection(url, user, password, client_strategy=ldap3.RESTARTABLE, auto_bind=True, raise_exceptions=True)
return self.connection != None
......@@ -157,6 +157,7 @@ class LDAPExport(object):
self.user_set_membership(username, groupname, True)
def user_set_membership(self, username, groupname, active):
msg = ("Set membership: of %s, in %s, to %s", username, groupname, active)
try:
self.connection.modify('cn=%s,%s' % (groupname, self.group_base), {
'memberUid': [
......@@ -165,6 +166,10 @@ class LDAPExport(object):
})
except (LDAPAttributeOrValueExistsResult if active else LDAPNoSuchAttributeResult):
pass
except Exception:
logger.exception(*msg)
return
logger.info(*msg)
def user_set_password(self, name, password):
dn = 'cn=%s,%s' % (name, self.user_base)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment