user whoami

Added a whoami option to the user, allows the user to query their own information based on their Kerberos principal
This commit is contained in:
Adam Young
2010-09-10 21:25:04 -04:00
parent 67a4549519
commit bef0690a2f

View File

@@ -51,6 +51,7 @@ from ipalib import api, errors
from ipalib import Flag, Int, Password, Str
from ipalib.plugins.baseldap import *
from ipalib import _, ngettext
from ipalib import util
class user(LDAPObject):
@@ -241,6 +242,16 @@ class user_find(LDAPSearch):
Search for users.
"""
takes_options = (
Flag('whoami',
label=_('Self'),
doc=_('Display user record for current Kerberos principal'),
),
)
def pre_callback(self, ldap, dn, entry_attrs, attrs_list, *keys, **options):
if options.get('whoami', True):
return "(&(objectclass=posixaccount)(krbprincipalname="+util.get_current_principal() + "))"
msg_summary = ngettext(
'%(count)d user matched', '%(count)d users matched', 0
)