浏览代码

HUE-2835 [core] Fixed issue with DN's that have weird comma location

Chris Conner 10 年之前
父节点
当前提交
c08f1584dc
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      apps/useradmin/src/useradmin/views.py

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

@@ -582,6 +582,11 @@ def _import_ldap_users_info(connection, user_info, sync_groups=False, import_by_
       # covers AD, Standard Ldap and posixAcount/posixGroup
       # covers AD, Standard Ldap and posixAcount/posixGroup
       if not group_filter.startswith('('):
       if not group_filter.startswith('('):
         group_filter = '(' + group_filter + ')'
         group_filter = '(' + group_filter + ')'
+
+      # Sanitizing the DN before using in a Search filter
+      sanitized_dn = ldap.filter.escape_filter_chars(ldap_info['dn']).replace(r'\2a', r'*')
+      sanitized_dn = sanitized_dn.replace(r'\5c,', r'\2c')
+
       find_groups_filter = "(&" + group_filter + "(|(" + group_member_attr + "=" + ldap_info['username'] + ")(" + \
       find_groups_filter = "(&" + group_filter + "(|(" + group_member_attr + "=" + ldap_info['username'] + ")(" + \
                            group_member_attr + "=" + ldap_info['dn'] + ")))"
                            group_member_attr + "=" + ldap_info['dn'] + ")))"
       group_ldap_info = connection.find_groups("*", group_filter=find_groups_filter)
       group_ldap_info = connection.find_groups("*", group_filter=find_groups_filter)