9991ea
From 2d1a85606d61128611f49101854bb8efe4abd638 Mon Sep 17 00:00:00 2001
9991ea
From: Alexander Bokovoy <abokovoy@redhat.com>
9991ea
Date: Thu, 16 Jan 2014 20:31:37 +0200
9991ea
Subject: [PATCH 32/34] group-show: resolve external members of the groups
9991ea
9991ea
Perform SID to name conversion for existing external members of the
9991ea
groups if trust is configured.
9991ea
9991ea
https://bugzilla.redhat.com/show_bug.cgi?id=1054391
9991ea
https://fedorahosted.org/freeipa/ticket/4123
9991ea
---
9991ea
 ipalib/plugins/group.py | 15 +++++++++++++++
9991ea
 1 file changed, 15 insertions(+)
9991ea
9991ea
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
9991ea
index 02eeb10ca2ca2a5710e88d6e3c11f1d1cdaa4a7b..dac55003e5a4291e8a3b7db58ae9b3c9c76e271e 100644
9991ea
--- a/ipalib/plugins/group.py
9991ea
+++ b/ipalib/plugins/group.py
9991ea
@@ -387,6 +387,21 @@ def pre_callback(self, ldap, filter, attrs_list, base_dn, scope, *args, **option
9991ea
 class group_show(LDAPRetrieve):
9991ea
     __doc__ = _('Display information about a named group.')
9991ea
     has_output_params = LDAPRetrieve.has_output_params + (ipaexternalmember_param,)
9991ea
+    def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
9991ea
+        assert isinstance(dn, DN)
9991ea
+        if ('ipaexternalmember' in entry_attrs and
9991ea
+            len(entry_attrs['ipaexternalmember']) > 0 and
9991ea
+            'trust_resolve' in self.Command and
9991ea
+            not options.get('raw', False)):
9991ea
+            sids = entry_attrs['ipaexternalmember']
9991ea
+            result = self.Command.trust_resolve(sids=sids)
9991ea
+            for entry in result['result']:
9991ea
+                try:
9991ea
+                    idx = sids.index(entry['sid'][0])
9991ea
+                    sids[idx] = entry['name'][0]
9991ea
+                except ValueError:
9991ea
+                    pass
9991ea
+        return dn
9991ea
 api.register(group_show)
9991ea
 
9991ea
 
9991ea
-- 
9991ea
1.8.4.2
9991ea