Bläddra i källkod

[useradmin] LDAP group search merge issue fix

abec 13 år sedan
förälder
incheckning
ebed8c5

+ 2 - 2
apps/useradmin/src/useradmin/ldap_access.py

@@ -133,11 +133,11 @@ class LdapConnection(object):
       group_filter = '(' + group_filter + ')'
     group_name_attr = desktop.conf.LDAP.GROUPS.GROUP_NAME_ATTR.get()
 
+    # Allow wild cards on non distinguished names
+    sanitized_name = ldap.filter.escape_filter_chars(groupname_pattern).replace(r'\2a', r'*')
     if find_by_dn:
-      sanitized_name = ldap.filter.escape_filter_chars(groupname_pattern).replace(r'\2a', r'*')
       group_name_filter = '(distinguishedName=' + sanitized_name + ')'
     else:
-      sanitized_name = ldap.filter.escape_filter_chars(groupname_pattern)
       group_name_filter = '(' + group_name_attr + '=' + sanitized_name + ')'
     ldap_filter = '(&' + group_filter + group_name_filter + ')'
 

+ 4 - 0
apps/useradmin/src/useradmin/tests.py

@@ -485,6 +485,10 @@ def test_add_ldap_groups():
   response = c.post(URL, dict(groupname_pattern='toolongnametoolongnametoolongname'))
   assert_true('30 characters or fewer' in response.context['form'].errors['groupname_pattern'][0], response)
 
+  # Test wild card
+  response = c.post(URL, dict(groupname_pattern='*r*'))
+  assert_true('/useradmin/groups' in response['Location'], response)
+
 def test_sync_ldap_users_groups():
   URL = reverse(sync_ldap_users_groups)