summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin McCarthy <kmccarth@redhat.com>2007-09-25 15:44:49 -0700
committerKevin McCarthy <kmccarth@redhat.com>2007-09-25 15:44:49 -0700
commitfa7759684f97f1faa174db234865cea6442ac6f8 (patch)
tree65363205d758c7d107c61fc53309f6feeb2fbd63
parent765279d82b24da0aac1821fea0c4c02859ffe00c (diff)
downloadfreeipa-fa7759684f97f1faa174db234865cea6442ac6f8.tar.gz
freeipa-fa7759684f97f1faa174db234865cea6442ac6f8.tar.xz
freeipa-fa7759684f97f1faa174db234865cea6442ac6f8.zip
Adds manager and direct reports to usershow page.
Fixes a bug with the group by member where is wasn't trapping not found errors.
-rw-r--r--ipa-python/ipaclient.py9
-rw-r--r--ipa-python/rpcclient.py17
-rw-r--r--ipa-server/ipa-gui/ipagui/controllers.py14
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/usershow.kid15
-rw-r--r--ipa-server/xmlrpc-server/funcs.py18
-rw-r--r--ipa-server/xmlrpc-server/ipaxmlrpc.py1
6 files changed, 71 insertions, 3 deletions
diff --git a/ipa-python/ipaclient.py b/ipa-python/ipaclient.py
index 6fbd41d58..3093fa976 100644
--- a/ipa-python/ipaclient.py
+++ b/ipa-python/ipaclient.py
@@ -68,6 +68,15 @@ class IPAClient:
result = self.transport.get_user_by_dn(dn,sattrs)
return user.User(result)
+ def get_users_by_manager(self,manager_dn,sattrs=None):
+ """Gets the users the report to a particular manager.
+ 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_users_by_manager(manager_dn, sattrs)
+
+ return map(lambda result: user.User(result), results)
+
def add_user(self,user,user_container=None):
"""Add a user. user is a ipa.user.User object"""
diff --git a/ipa-python/rpcclient.py b/ipa-python/rpcclient.py
index c662761cf..9d9990448 100644
--- a/ipa-python/rpcclient.py
+++ b/ipa-python/rpcclient.py
@@ -101,6 +101,23 @@ class RPCClient:
return ipautil.unwrap_binary_data(result)
+ def get_users_by_manager(self,manager_dn,sattrs=None):
+ """Gets the users that report to a manager.
+ 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_users_by_manager(manager_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_user(self,user,user_container=None):
"""Add a new user. 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 11ce48a73..14213461c 100644
--- a/ipa-server/ipa-gui/ipagui/controllers.py
+++ b/ipa-server/ipa-gui/ipagui/controllers.py
@@ -252,8 +252,20 @@ class Root(controllers.RootController):
try:
user = client.get_user_by_uid(uid, user_fields)
user_groups = client.get_groups_by_member(user.dn, ['cn'])
+ user_reports = client.get_users_by_manager(user.dn,
+ ['givenname', 'sn', 'uid'])
+
+ user_manager = None
+ try:
+ if user.manager:
+ user_manager = client.get_user_by_dn(user.manager,
+ ['givenname', 'sn', 'uid'])
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ pass
+
return dict(user=user.toDict(), fields=forms.user.UserFields(),
- user_groups=user_groups)
+ user_groups=user_groups, user_reports=user_reports,
+ user_manager=user_manager)
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 5092a427f..a71f683df 100644
--- a/ipa-server/ipa-gui/ipagui/templates/usershow.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/usershow.kid
@@ -78,6 +78,15 @@ else:
</th>
<td>${user.get("telephonenumber")}</td>
</tr>
+ <tr py:if='user_manager'>
+ <th>
+ Manager:
+ </th>
+ <td>
+ <a href="${tg.url('/usershow', uid=user_manager.uid)}"
+ >${user_manager.givenname} ${user_manager.sn}</a>
+ </td>
+ </tr>
</table>
<div class="formsection">Account Status</div>
@@ -90,6 +99,12 @@ else:
</tr>
</table>
+ <div class="formsection" py:if='len(user_reports) &gt; 0'>Direct Reports</div>
+ <div py:for="report in user_reports">
+ <a href="${tg.url('/usershow', uid=report.uid)}"
+ >${report.givenname} ${report.sn}</a>
+ </div>
+
<div class="formsection">Groups</div>
<div py:for="group in user_groups">
<a href="${tg.url('/groupshow', cn=group.cn)}">${group.cn}</a>
diff --git a/ipa-server/xmlrpc-server/funcs.py b/ipa-server/xmlrpc-server/funcs.py
index 2f9606d0f..d226ac863 100644
--- a/ipa-server/xmlrpc-server/funcs.py
+++ b/ipa-server/xmlrpc-server/funcs.py
@@ -308,7 +308,18 @@ class IPAServer:
filter = "(objectClass=*)"
return self.__get_entry(dn, filter, sattrs, opts)
-
+
+ def get_users_by_manager (self, manager_dn, sattrs=None, opts=None):
+ """Gets the users that report to a particular manager.
+ """
+
+ filter = "(&(objectClass=person)(manager=%s))" % manager_dn
+
+ try:
+ return self.__get_list(self.basedn, filter, sattrs, opts)
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ return []
+
def add_user (self, user, user_container=None, opts=None):
"""Add a user in LDAP. Takes as input a dict where the key is the
attribute name and the value is either a string or in the case
@@ -601,7 +612,10 @@ class IPAServer:
filter = "(&(objectClass=posixGroup)(uniqueMember=%s))" % member_dn
- return self.__get_list(self.basedn, filter, sattrs, opts)
+ try:
+ return self.__get_list(self.basedn, filter, sattrs, opts)
+ except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
+ return []
def add_group (self, group, group_container=None, opts=None):
"""Add a group in LDAP. Takes as input a dict where the key is the
diff --git a/ipa-server/xmlrpc-server/ipaxmlrpc.py b/ipa-server/xmlrpc-server/ipaxmlrpc.py
index baeb50707..aa9044642 100644
--- a/ipa-server/xmlrpc-server/ipaxmlrpc.py
+++ b/ipa-server/xmlrpc-server/ipaxmlrpc.py
@@ -316,6 +316,7 @@ def handler(req, profiling=False):
h = ModXMLRPCRequestHandler()
h.register_function(f.get_user_by_uid)
h.register_function(f.get_user_by_dn)
+ h.register_function(f.get_users_by_manager)
h.register_function(f.add_user)
h.register_function(f.get_add_schema)
h.register_function(f.get_all_users)