# How to get the loggedin user in kibana/xpack

**URL:** <https://discuss.elastic.co/t/how-to-get-the-loggedin-user-in-kibana-xpack/187727>\
**Category:** Kibana\
**Tags:** elastic-stack-security\
**Created:** [June 27, 2019, 6:07am UTC](https://discuss.elastic.co/t/how-to-get-the-loggedin-user-in-kibana-xpack/187727 "2019-06-27T06:07:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SukeshGupta](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@SukeshGupta](https://discuss.elastic.co/u/SukeshGupta)\
**Post date:** [June 27, 2019, 6:07am UTC](https://discuss.elastic.co/t/how-to-get-the-loggedin-user-in-kibana-xpack/187727/1 "2019-06-27T06:07:22Z")

</div>

Hi,

I have a json document like below indexed in ES:  
{  
"company" : "abc",  
"users": ["john","smith","wills","jacob"]  
}

In kibana while create the roles i am granting read privileges to specific document like below:  
{"match": {"users": "john"}} - Here i need to pass logged in user name dynamically.

Can you please help me in getting the logged in user name. Thanks!

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [June 27, 2019, 8:04am UTC](https://discuss.elastic.co/t/how-to-get-the-loggedin-user-in-kibana-xpack/187727/2 "2019-06-27T08:04:26Z")

</div>

I don't quite follow what you're asking for, but I think you want [Templated Role Queries](https://www.elastic.co/guide/en/elastic-stack-overview/7.2/field-and-document-access-control.html#templating-role-query).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 25, 2019, 8:04am UTC](https://discuss.elastic.co/t/how-to-get-the-loggedin-user-in-kibana-xpack/187727/3 "2019-07-25T08:04:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
