Limit users to access Variable values

It looks like that variable does exist

based on the above here is an example with sample ddl & dml

use grafana 
--this is my own ms sql server database 
--for testing things out not grafana's db

go

drop table companies

create table companies(companyid int identity(1,1), 
companyname varchar(50) )

insert into companies
select 'Acme' union
select 'Zimza'


drop table users;
create table users(username varchar(50))

insert into users
select 'ddenson'


drop table usercompanies
create table usercompanies(username varchar(50), 
companyid int)

insert into usercompanies
select u.username, c.companyid
from companies c , users u
where c.companyname = 'Acme'

here is how the companies variable is setup

here is an ms sql profiler showing that it does work when I am logged in ddenson

image

and the resulting Companies drop down (not sure why the 1 is there) but you get the drift.
as you can see ddenson only sees the company he is associated with = Acme.

image

just implement this principle to your environment and whatever backend you use

1 Like