mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Adds manager and direct reports to usershow page.
Fixes a bug with the group by member where is wasn't trapping not found errors.
This commit is contained in:
@@ -68,6 +68,15 @@ class IPAClient:
|
|||||||
result = self.transport.get_user_by_dn(dn,sattrs)
|
result = self.transport.get_user_by_dn(dn,sattrs)
|
||||||
return user.User(result)
|
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):
|
def add_user(self,user,user_container=None):
|
||||||
"""Add a user. user is a ipa.user.User object"""
|
"""Add a user. user is a ipa.user.User object"""
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,23 @@ class RPCClient:
|
|||||||
|
|
||||||
return ipautil.unwrap_binary_data(result)
|
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):
|
def add_user(self,user,user_container=None):
|
||||||
"""Add a new user. Takes as input a dict where the key is the
|
"""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
|
attribute name and the value is either a string or in the case
|
||||||
|
|||||||
@@ -252,8 +252,20 @@ class Root(controllers.RootController):
|
|||||||
try:
|
try:
|
||||||
user = client.get_user_by_uid(uid, user_fields)
|
user = client.get_user_by_uid(uid, user_fields)
|
||||||
user_groups = client.get_groups_by_member(user.dn, ['cn'])
|
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(),
|
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:
|
except ipaerror.IPAError, e:
|
||||||
turbogears.flash("User show failed: " + str(e))
|
turbogears.flash("User show failed: " + str(e))
|
||||||
raise turbogears.redirect("/")
|
raise turbogears.redirect("/")
|
||||||
|
|||||||
@@ -78,6 +78,15 @@ else:
|
|||||||
</th>
|
</th>
|
||||||
<td>${user.get("telephonenumber")}</td>
|
<td>${user.get("telephonenumber")}</td>
|
||||||
</tr>
|
</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>
|
</table>
|
||||||
|
|
||||||
<div class="formsection">Account Status</div>
|
<div class="formsection">Account Status</div>
|
||||||
@@ -90,6 +99,12 @@ else:
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<div class="formsection" py:if='len(user_reports) > 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 class="formsection">Groups</div>
|
||||||
<div py:for="group in user_groups">
|
<div py:for="group in user_groups">
|
||||||
<a href="${tg.url('/groupshow', cn=group.cn)}">${group.cn}</a>
|
<a href="${tg.url('/groupshow', cn=group.cn)}">${group.cn}</a>
|
||||||
|
|||||||
@@ -308,7 +308,18 @@ class IPAServer:
|
|||||||
|
|
||||||
filter = "(objectClass=*)"
|
filter = "(objectClass=*)"
|
||||||
return self.__get_entry(dn, filter, sattrs, opts)
|
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):
|
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
|
"""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
|
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
|
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):
|
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
|
"""Add a group in LDAP. Takes as input a dict where the key is the
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ def handler(req, profiling=False):
|
|||||||
h = ModXMLRPCRequestHandler()
|
h = ModXMLRPCRequestHandler()
|
||||||
h.register_function(f.get_user_by_uid)
|
h.register_function(f.get_user_by_uid)
|
||||||
h.register_function(f.get_user_by_dn)
|
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.add_user)
|
||||||
h.register_function(f.get_add_schema)
|
h.register_function(f.get_add_schema)
|
||||||
h.register_function(f.get_all_users)
|
h.register_function(f.get_all_users)
|
||||||
|
|||||||
Reference in New Issue
Block a user