[sysadmin-bin] conn.modify_s needs a bytestring



commit ad477e3b37a5ac87a02ab75a943ab69639335dc6
Author: Andrea Veri <averi redhat com>
Date:   Tue Jan 19 11:26:55 2021 +0100

    conn.modify_s needs a bytestring

 gnome_ldap_utils.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/gnome_ldap_utils.py b/gnome_ldap_utils.py
index d890feb..2f0bb26 100755
--- a/gnome_ldap_utils.py
+++ b/gnome_ldap_utils.py
@@ -89,13 +89,14 @@ class Gnome_ldap_utils:
     def add_user_to_ldap_group(self, userid, group):
         import ldap
 
-        add_members = [(ldap.MOD_ADD, 'member', 'uid=%s,%s' % (userid, self.LDAP_USER_BASE))]
+        uid_query = "uid={},{}".format(userid, self.LDAP_USER_BASE).encode()
+        add_members = [(ldap.MOD_ADD, 'member', uid_query)]
         self.conn.modify_s('cn=%s,%s' % (group, self.LDAP_GROUP_BASE), add_members)
 
     def remove_user_from_ldap_group(self, userid, group):
         import ldap
 
-        uid_query = "uid={},{}".format(userid, self.LDAP_USER_BASE).encode("utf-8")
+        uid_query = "uid={},{}".format(userid, self.LDAP_USER_BASE).encode()
         remove_members = [(ldap.MOD_DELETE, 'member', uid_query)]
         self.conn.modify_s('cn=%s,%s' % (group, self.LDAP_GROUP_BASE), remove_members)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]