[sysadmin-bin] Revert "unbind from LDAP to avoid stale connections whenever the LDAP servers goes into maintenance/



commit d7c7a41c95e63dc55c791a6f9dcb4537988d1508
Author: Andrea Veri <averi redhat com>
Date:   Tue May 11 16:07:35 2021 +0200

    Revert "unbind from LDAP to avoid stale connections whenever the LDAP servers goes into 
maintenance/downtime"
    
    This reverts commit 1f5fb14cf98bfa4c9231ef875e745dbe455a4c1f.
    
    unbind_ext is already called as part of the python ldap class methods.
    We may need ldap.ldapobject.ReconnectLDAPObject for password-resets.

 gnome_ldap_utils.py | 9 ---------
 1 file changed, 9 deletions(-)
---
diff --git a/gnome_ldap_utils.py b/gnome_ldap_utils.py
index 1e4fad3..2f0bb26 100755
--- a/gnome_ldap_utils.py
+++ b/gnome_ldap_utils.py
@@ -27,7 +27,6 @@ class Gnome_ldap_utils:
 
         filter = ldap.filter.filter_format('(&(objectClass=groupofnames)(cn=%s))', (group, ))
         results = self.conn.search_s(self.LDAP_GROUP_BASE, ldap.SCOPE_SUBTREE, filter, ('member', ))
-        self.conn.unbind_s()
 
         members = set()
 
@@ -62,8 +61,6 @@ class Gnome_ldap_utils:
         else:
             result = self.conn.search_s(self.LDAP_USER_BASE, ldap.SCOPE_SUBTREE, filter, ('uid', attr, ))
 
-        self.conn.unbind_s()
-
         if len(results) > 0:
             return results
         elif len(result) > 0:
@@ -88,7 +85,6 @@ class Gnome_ldap_utils:
 
         replace_password = [(ldap.MOD_REPLACE, 'userPassword', password)]
         self.conn.modify_s('uid=%s,%s' % (userid, self.LDAP_USER_BASE), replace_password)
-        self.conn.unbind_s()
 
     def add_user_to_ldap_group(self, userid, group):
         import ldap
@@ -96,7 +92,6 @@ class Gnome_ldap_utils:
         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)
-        self.conn.unbind_s()
 
     def remove_user_from_ldap_group(self, userid, group):
         import ldap
@@ -104,7 +99,6 @@ class Gnome_ldap_utils:
         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)
-        self.conn.unbind_s()
 
     def add_or_update_description(self, userid, comment, add=False, update=False):
         import sys
@@ -113,11 +107,8 @@ class Gnome_ldap_utils:
         if add and not update:
             update_comment = [(ldap.MOD_ADD, 'description', comment.encode())]
             self.conn.modify_s('uid=%s,%s' % (userid, self.LDAP_USER_BASE), update_comment)
-            self.conn.unbind_s()
         elif update and not add:
             update_comment = [(ldap.MOD_REPLACE, 'description', comment.encode())]
             self.conn.modify_s('uid=%s,%s' % (userid, self.LDAP_USER_BASE), update_comment)
-            self.conn.unbind_s()
         else:
-            self.conn.unbind_s()
             sys.exit(1)


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