| Request | LDAPMultiPlugins -- bug report -- by Wichert Akkerman |
| Posted on | Jan 30, 2006 11:01 am |
| Subscribe |
| Comment by Jens Vagelpohl on Feb 1, 2006 3:18 pm | |
|
Thanks Wichert, fix applied and checked in. |
|
|
|
| Comment by Wichert Akkerman on Jan 31, 2006 7:06 pm | |
|
Further testing found a bug in my patch: if you submit an empty id the search filter will contain an try like (group=**) which is incorrect. The patch below fixes this by only testing for attribute existance if no id was specified (None or empty string). Index: ActiveDirectoryMultiPlugin.py =================================================================== --- ActiveDirectoryMultiPlugin.py (revision 1281) +++ ActiveDirectoryMultiPlugin.py (working copy) @@ -370,9 +370,11 @@ plugin_id = self.getId() filt = ['(objectClass=%s)' % self.group_class] - if exact_match: + if not test_id: + filt.append('(%s=*)') % self.groupid_attr + elif exact_match: filt.append('(%s=%s)') % (self.groupid_attr, test_id) - else: + elif test_id: filt.append('(%s=*%s*)') % (self.groupid_attr, test_id) filt = '(&%s)' % ''.join(filt) |
|
|
|
| Resolve by Jens Vagelpohl on Jan 30, 2006 3:57 pm | |
|
Patch applied, thanks again! |
|
|
|
| Comment by Wichert Akkerman on Jan 30, 2006 11:06 am | |
| I hit submit a bit too fast; that should be enumerateGroups, not searchGroup. |
|
|
|
| Accept by Jens Vagelpohl on Jan 30, 2006 11:04 am | |
|
Thanks Wichert, that looks good. I'll merge it in the next few days. |
|
|
|
| Initial Request by Wichert Akkerman on Jan 30, 2006 11:01 am | |
|
In environment which a large number of groups the current searchGroup implementation in ActiveDirectoryMultiPlugin has two problems: it will hit the search result, and doing the filtering of results in python instead of in the LDAP server is slow. Since all PAS plugins seem to be case sensitive both problems can be solved by letting the LDAP server itself do all the filtering. The patch below implements this. Index: ActiveDirectoryMultiPlugin.py =================================================================== --- ActiveDirectoryMultiPlugin.py (revision 1280) +++ ActiveDirectoryMultiPlugin.py (working copy) @@ -367,10 +367,14 @@ elif id is None: id = '' - test_id = id.lower() plugin_id = self.getId() - filt = '(objectClass=%s)' % self.group_class + filt = ['(objectClass=%s)' % self.group_class] + if exact_match: + filt.append('(%s=%s)') % (self.groupid_attr, test_id) + else: + filt.append('(%s=*%s*)') % (self.groupid_attr, test_id) + filt = '(&%s)' % ''.join(filt) delegate = acl._delegate R = delegate.search(acl.groups_base, acl.groups_scope, filter=filt) @@ -380,19 +384,13 @@ groups = R['results'] - if exact_match: - tester = operator.eq - else: - tester = operator.contains - results = [] for group in groups: tmp = {} tmp['title'] = '(Group) ' + group[self.grouptitle_attr][0] id = tmp['id'] = group[self.groupid_attr][0] tmp['pluginid'] = plugin_id - if tester(id.lower(), test_id): - results.append(tmp) + results.append(tmp) if sort_by is not None: results.sort(lambda a, b: cmp( a.get(sort_by, '').lower() |