# Limit users to access Variable values

**URL:** <https://community.grafana.com/t/limit-users-to-access-variable-values/8513>\
**Category:** Elasticsearch\
**Tags:** templating\
**Created:** [July 3, 2018, 10:00am UTC](https://community.grafana.com/t/limit-users-to-access-variable-values/8513 "2018-07-03T10:00:59Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [July 31, 2022, 1:40am UTC](https://community.grafana.com/t/limit-users-to-access-variable-values/8513/12 "2022-07-31T01:40:42Z")

</div>

One way would be to query the companies data by passing in the currently logged in username. For example if ajames is in company A and dvader is in company dark side

the user name, if available as a global value, is passed to the company names query.  
not sure if there is such a global \_\_currently\_loggedin\_user value.

an example in sql server

```auto
-- @username is of course passed in to the query 
--on grafana side that creates the companies list

select c.companyid , c.name
  from companies c 
  join companyuser cu on c.companyid = cu.companyid
join users u on u.userid = cu.userid
where u.samaccountname = @username

```

this is based on the following principle: access control list

> **[Access-control list](https://en.wikipedia.org/wiki/Access-control_list)**
>
> In computer security, an access-control list (ACL) is a list of permissions associated with a system resource (object). An ACL specifies which users or system processes are granted access to objects, as well as what operations are allowed on given objects. Each entry in a typical ACL specifies a subject and an operation. For instance, if a file object has an ACL that contains (Alice: read,write; Bob: read), this would give Alice permission to read and write the file and give Bob permission on Ma...

---

_[View the full topic](https://community.grafana.com/t/limit-users-to-access-variable-values/8513)._
