user whoami
Added a whoami option to the user, allows the user to query their own information based on their Kerberos principal



https://fedorahosted.org/freeipa/attachment/ticket/47/admiyo-freeipa-0023-user-whoami.patch

This will be used to return the users principal and rolegroups.


Test with :

curl -H "Content-Type:application/json" -H "Accept:applicaton/json" -H "Accept-Language:es" --negotiate -u : --cacert /etc/ipa/ca.crt -d '{"method:"user_find","params":[[],{ "all":true,"whoami":"True" } ],"id":0}' -X POST http://127.0.0.1:8888/ipa/json



as well as

ipa user-find --whoami --all
>From 903e9978c3a98f3746748b782a92136b75546a93 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Fri, 10 Sep 2010 21:25:04 -0400
Subject: [PATCH] user whoami
 Added a whoami option to the user, allows the user to query their own information based on their Kerberos principal

---
 ipalib/plugins/user.py |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 5841d7a..803ee10 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
     )
-- 
1.7.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to