diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py index 880b47852..6fbd41d58 100644 --- a/ipa-python/ipaclient.py +++ b/ipa-python/ipaclient.py @@ -160,6 +160,15 @@ class IPAClient: result = self.transport.get_group_by_dn(dn,sattrs) return group.Group(result) + def get_groups_by_member(self,member_dn,sattrs=None): + """Gets the groups that member_dn belongs to. + If sattrs is not None then only those + attributes will be returned, otherwise all available + attributes are returned. The result is a list of groups.""" + results = self.transport.get_groups_by_member(member_dn,sattrs) + + return map(lambda result: group.Group(result), results) + def add_group(self,group,group_container=None): """Add a group. group is a ipa.group.Group object""" diff --git a/ipa-python/rpcclient.py b/ipa-python/rpcclient.py index 21ea68bc6..c662761cf 100644 --- a/ipa-python/rpcclient.py +++ b/ipa-python/rpcclient.py @@ -258,6 +258,23 @@ class RPCClient: return ipautil.unwrap_binary_data(result) + def get_groups_by_member(self,member_dn,sattrs=None): + """Gets the groups that member_dn belongs to. + If sattrs is not None then only those + attributes will be returned, otherwise all available + attributes are returned. The result is a list of dicts.""" + server = self.setup_server() + if sattrs is None: + sattrs = "__NONE__" + try: + result = server.get_groups_by_member(member_dn, sattrs) + except xmlrpclib.Fault, fault: + raise ipaerror.gen_exception(fault.faultCode, fault.faultString) + except socket.error, (value, msg): + raise xmlrpclib.Fault(value, msg) + + return ipautil.unwrap_binary_data(result) + def add_group(self,group,group_container=None): """Add a new group. Takes as input a dict where the key is the attribute name and the value is either a string or in the case diff --git a/ipa-server/ipa-gui/ipagui/controllers.py b/ipa-server/ipa-gui/ipagui/controllers.py index c1aa5e860..11ce48a73 100644 --- a/ipa-server/ipa-gui/ipagui/controllers.py +++ b/ipa-server/ipa-gui/ipagui/controllers.py @@ -251,7 +251,9 @@ class Root(controllers.RootController): client.set_krbccache(os.environ["KRB5CCNAME"]) try: user = client.get_user_by_uid(uid, user_fields) - return dict(user=user.toDict(), fields=forms.user.UserFields()) + user_groups = client.get_groups_by_member(user.dn, ['cn']) + return dict(user=user.toDict(), fields=forms.user.UserFields(), + user_groups=user_groups) except ipaerror.IPAError, e: turbogears.flash("User show failed: " + str(e)) raise turbogears.redirect("/") diff --git a/ipa-server/ipa-gui/ipagui/templates/usershow.kid b/ipa-server/ipa-gui/ipagui/templates/usershow.kid index aff400c54..5092a427f 100644 --- a/ipa-server/ipa-gui/ipagui/templates/usershow.kid +++ b/ipa-server/ipa-gui/ipagui/templates/usershow.kid @@ -90,6 +90,14 @@ else: +