summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/user.py
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2010-09-10 21:25:04 -0400
committerAdam Young <ayoung@redhat.com>2010-09-14 13:57:56 -0400
commitbef0690a2ff9cccf7de132e5e64b4ba631482764 (patch)
tree9c8e8379b55d7e5f59c6f7bcd0de53ea4c8e96d5 /ipalib/plugins/user.py
parent67a454951993b1f04f3feeab7462dcaf6d23fb61 (diff)
downloadfreeipa.git-bef0690a2ff9cccf7de132e5e64b4ba631482764.tar.gz
freeipa.git-bef0690a2ff9cccf7de132e5e64b4ba631482764.tar.xz
freeipa.git-bef0690a2ff9cccf7de132e5e64b4ba631482764.zip
user whoami
Added a whoami option to the user, allows the user to query their own information based on their Kerberos principal
Diffstat (limited to 'ipalib/plugins/user.py')
-rw-r--r--ipalib/plugins/user.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 5841d7a0..803ee108 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -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
)