Ticket #251

Pavel
>From 1bb54788dca503a7b6e25e2fc13a8852174a3827 Mon Sep 17 00:00:00 2001
From: Pavel Zuna <pz...@redhat.com>
Date: Tue, 21 Sep 2010 13:03:40 -0400
Subject: [PATCH 1/3] Add flag to group-find to only search on private groups.

Ticket #251
---
 ipalib/plugins/group.py |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 616eff2..b3b6747 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -184,7 +184,6 @@ class group_mod(LDAPUpdate):
     """
     Modify a group.
     """
-
     msg_summary = _('Modified group "%(value)s"')
 
     takes_options = LDAPUpdate.takes_options + (
@@ -214,11 +213,24 @@ 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('privateonly',
+            cli_name='privateonly',
+            doc=_('search for private groups only'),
+        ),
+    )
+
+    def pre_callback(self, ldap, filter, attrs_list, base_dn, *args, **options):
+        if options['privateonly']:
+            objclass = ['posixGroup', 'mepManagedEntry']
+            flt = ldap.make_filter_from_attr('objectclass', objclass)
+            filter = ldap.combine_filters([filter, flt], ldap.MATCH_ALL)
+        return filter
+
 api.register(group_find)
 
 
-- 
1.7.1.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to