Forum Discussion
Masking a column based on user login
I know this answer is wayyyy overdue, but the solution to the problem has been provided by combining two answers into one...
Step 1) Create a mapping Table that maps the UserPrincipalName to your permisisons. let's say
UPN = alex@contoso
Permission = Masked
UPN = manager@contoso
Permission = All
then create a Role in RLS to filter the Permission Table based onn UPN=UserPrincipalName(). so their Login will automatically filter that table.
then in your Table you can use a calculated field with a Lookup for Min(Permission)="All" in the permission table to display the data or not. you won't be using the UserPrincipalName in the field at all. that already did its magic when the user opened the report.
Even better would be to separate out the sensitive data into a separate table with a 1-1 match on the orginal one and use relationships to filter the data already at Row Level. In that way the user can't even circumvent the masking if they start using Self-Service features like QnA or online report editing.
i.e.
Original:
ID = 1
Name=Alex
Creditcard = 1234-4567-9012-4444
New:
Employee:
ID = 1
Name=Alex
Sensitive:
ID = 1
Creditcard = 1234-4567-9012-4444
Permission = "HR"
Permissions:
UPN=alex@contoso
Permission = "HR"
Add a m-n relationship between Permissions and Senstive based on the Permission Column with security filter applied.
Add a 1-1 relationship between Employee and Sensitive based on ID column
Then either just drag the fields together on the fly, or add a new calculated column that shows a mask "****-****-****-****" when no Related(Creditcard) is found.
Don't forget to apply the RLS with the UPN on the Permission table though...
Hope this all makes sense!
Hi alxdean,
Thanks for your contribution. I have tried your solution and I have a problem with MIN in the Calculated column.
Calculated column is calculated on the Permission tabe even before the RLS is applied on it. MIN(PERMISSION) = "ALL" always even when the PERMISSION table is having only one record with PERMISSION = "MASKED" after RLS is applied.
So data is never masked in this case. Am I missing something?
Thanks in advance for your reply.
- Anonymous5 years agoNot applicable
Yeah, I tried different options in the end and the MIN option won't work, as you said, it is evaluated before the RLS is applied. A real bummer! So the only option available is to use related tables and enforce RLS via the relationship. You won't be able to use RLS with calculated columns. I.e. move the sensitive data out to a related table and lock it down with RLS.