Explorar o código

HUE-8692 [useradmin] Fix group sync stops when a group member is not found

Ben Gooley %!s(int64=6) %!d(string=hai) anos
pai
achega
9e50d5b

+ 11 - 6
apps/useradmin/src/useradmin/ldap_access.py

@@ -346,13 +346,18 @@ class LdapConnection(object):
     self._ldap_filter = ldap_filter
     self._attrlist = attrlist
 
-    ldap_result_id = self.ldap_handle.search(search_dn, scope, ldap_filter, attrlist)
-    result_type, result_data = self.ldap_handle.result(ldap_result_id)
+    try:
+      ldap_result_id = self.ldap_handle.search(search_dn, scope, ldap_filter, attrlist)
+      result_type, result_data = self.ldap_handle.result(ldap_result_id)
 
-    if result_type == ldap.RES_SEARCH_RESULT:
-      return self._transform_find_user_results(result_data, user_name_attr)
-    else:
-      return []
+      if result_type == ldap.RES_SEARCH_RESULT:
+        return self._transform_find_user_results(result_data, user_name_attr)
+      else:
+        return []
+    except ldap.LDAPError, e:
+       LOG.warn("LDAP Error: %s" % e)
+
+    return None
 
   def find_groups(self, groupname_pattern, search_attr=None, group_name_attr=None, group_member_attr=None, group_filter=None, find_by_dn=False, scope=ldap.SCOPE_SUBTREE):
     """

+ 3 - 0
apps/useradmin/src/useradmin/views.py

@@ -1234,6 +1234,9 @@ def _import_ldap_suboordinate_groups(connection, groupname_pattern, import_membe
         except LdapSearchException, e:
           LOG.warn("Failed to find LDAP user: %s" % e)
 
+        if user_info is None:
+          continue
+
         if len(user_info) > 1:
           LOG.warn('Found multiple users for member %s.' % member)
         else: