summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/group.py
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-09-21 13:03:40 -0400
committerRob Crittenden <rcritten@redhat.com>2010-10-20 17:38:03 -0400
commit42c78a383d156e2ad7e6ae7832ccb1adc14d23c0 (patch)
tree9b7433f2bdbbe299244ae0cdd221f026ed1da684 /ipalib/plugins/group.py
parent4f7f40004361d9a63f625e5e70d0969c41d43958 (diff)
downloadfreeipa-42c78a383d156e2ad7e6ae7832ccb1adc14d23c0.tar.gz
freeipa-42c78a383d156e2ad7e6ae7832ccb1adc14d23c0.tar.xz
freeipa-42c78a383d156e2ad7e6ae7832ccb1adc14d23c0.zip
Add flag to group-find to only search on private groups.
ticket #251
Diffstat (limited to 'ipalib/plugins/group.py')
-rw-r--r--ipalib/plugins/group.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 55d8dfd3e..2b8dc1af1 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -188,7 +188,6 @@ class group_mod(LDAPUpdate):
"""
Modify a group.
"""
-
msg_summary = _('Modified group "%(value)s"')
takes_options = LDAPUpdate.takes_options + (
@@ -218,11 +217,39 @@ class group_find(LDAPSearch):
"""
Search for groups.
"""
-
msg_summary = ngettext(
'%(count)d group matched', '%(count)d groups matched', 0
)
+ takes_options = LDAPSearch.takes_options + (
+ Flag('private',
+ cli_name='private',
+ doc=_('search for private groups'),
+ ),
+ )
+
+ def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
+ # if looking for private groups, we need to create a new search filter,
+ # because private groups have different object classes
+ if options['private']:
+ # filter based on options, oflt
+ search_kw = self.args_options_2_entry(**options)
+ search_kw['objectclass'] = ['posixGroup', 'mepManagedEntry']
+ oflt = ldap.make_filter(search_kw, rules=ldap.MATCH_ALL)
+
+ # filter based on 'criteria' argument
+ search_kw = {}
+ config = ldap.get_ipa_config()[1]
+ attrs = config.get(self.obj.search_attributes_config, [])
+ if len(attrs) == 1 and isinstance(attrs[0], basestring):
+ search_attrs = attrs[0].split(',')
+ for a in search_attrs:
+ search_kw[a] = args[-1]
+ cflt = ldap.make_filter(search_kw, exact=False)
+
+ filter = ldap.combine_filters((oflt, cflt), rules=ldap.MATCH_ALL)
+ return filter
+
api.register(group_find)