user-find whoami

Now no longer breaks user-find with a filter
Uses the corrected Params for getting option
printf style strings
This commit is contained in:
Adam Young 2010-09-14 16:50:00 -04:00
parent 30def30eaf
commit 5fd09b016b

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,18 @@ 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, filter, entry_attrs, attrs_list, *keys, **options):
if options.get('whoami'):
return "(&(objectclass=posixaccount)(krbprincipalname=%s))"%\
util.get_current_principal()
return filter
msg_summary = ngettext(
'%(count)d user matched', '%(count)d users matched', 0
)