Reputation: 73
I have situation where I need to create a view which will be used by end user who may have PII and NON-PII permission clearance controlled by AD groups.
Say I have dim_customer
which contains four columns ID
, Name
, DoB
, and Country
. When PII user runs:
Select ID, Name, DoB, Country FROM dim_customer
The PII user should get:
ID NAME DoB Country
1 John 1999-10-10 US
If the same query is run by NON-PII user then they should get:
ID NAME DoB Country
1 PII DATA PII DATA US
So basically same view object is used but data is displayed according to the PII clearance.
no select permission on Name and DoB Columns
I am looking for a solution where the query runs successfully and show results as above.
Is this possible in SQL Server ?
Thanks in advance.
Upvotes: 0
Views: 595
Reputation: 1353
Create two roles, one that allows PII data, and one that doesn't. Put each user into one role or the other. Than write your view
Select
ID,
Name,
CASE
WHEN IS_ROLEMEMBER ('pii_role') = 1 THEN DoB
ELSE 'PII Data'
END as DoB,
Country
FROM dim_customer
Upvotes: 0