diff --git a/canaille/ldaputils.py b/canaille/ldaputils.py index 9e5be236..bf828f71 100644 --- a/canaille/ldaputils.py +++ b/canaille/ldaputils.py @@ -171,7 +171,12 @@ class LDAPObject: if v and v[0] and self.attrs.get(k) != v } attributes = [ - (ldap.MOD_REPLACE, k, [elt.encode("utf-8") for elt in v]) + (ldap.MOD_REPLACE, k, [ + elt.encode("utf-8") + if isinstance(elt, str) + else elt + for elt in v + ]) for k, v in mods.items() ] conn.modify_s(self.dn, attributes) @@ -186,7 +191,13 @@ class LDAPObject: mods[k] = v attributes = [ - (k, [elt.encode("utf-8") for elt in v]) for k, v in mods.items() + (k, [ + elt.encode("utf-8") + if isinstance(elt, str) + else elt + for elt in v + ]) + for k, v in mods.items() ] conn.add_s(self.dn, attributes)