Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Dynamic Row Level Security Based on Contract

Hi,

I am trying to set up Dynamic Row Level Security for a  large dashboard where each contract should only see their reporting metrcis.  There are multiple people in a contract so I know it needs to be based on email but everyone should see their own contract only.

I have set up a Users Table, Employee Table and obvioulsly data.

 

I cannot seem to get the synxtax right so that I could view each dataset based upon the contract selected only.

Can anyone help?  I know I need two tables that I have to use the Userprincipalname function but I am struggling with the rest of this.

Sales- Desired

NameEmail AddressHire DateContractEmployeeIDUNIQUE CONTRACT AND NAMESales
A[email protected]13-Jun-18ABC1A-ABC10
E[email protected]29-Jul-19ABC5E-ABC125
F[email protected]16-Dec-19ABC6F-ABC50
K[email protected]23-Oct-19ABC11K-ABC75

 

Employee Table

NameEmailAddressHire DateEmployeeIDContractUnique ID
A[email protected]14-Sep-981ABCA-ABC
B[email protected]16-Nov-982CBDB-CBD
C[email protected]3-Oct-143DEFC-DEF
D[email protected]27-Nov-174GHID-GHI
E[email protected]9-Mar-185ABCE-ABC
F[email protected]29-Jun-016ABCF-ABC

 

Users Table

NameEmail AddressHire DateContractEmployeeIDUNIQUE CONTRACT AND NAME
A[email protected]13-Jun-18ABC1A-ABC
B[email protected]18-Jun-18CBD2B-CBD
C[email protected]25-Jan-21DEF3C-DEF
D[email protected]25-Oct-17GHI4D-GHI
E[email protected]29-Jul-19ABC5E-ABC
F[email protected]16-Dec-19ABC6F-ABC

7 Replies

  • yes, use USERPRINCIPALNAME and apply the RLS on the outermost dimension table of your data model.  

     

    What's the reason for having a user table and an employee table?

  • Anonymous's avatar
    Anonymous
    Not applicable

    I don't think I need both tables either but I had seen other examples where that worked.  I can never get the userprincipalname to work.  

    Are you really just using one filter on the email? Do you have an example? Thanks!

  • The usual pitfalls with RLS are 

    - you have users with workspace roles above viewer => RLS is ineffective

    - your data model links are pointing towards the RLS table => ditto.

     

    Other than that USERPRINCIPALNAME works "fine".

     

    Personal note:  Do you really need RLS?  Is your data sensitive? Because if not then all you are achieving is to irritate your users.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Data is super sensitive.

    In this case, how you you set up the formula in the manage roles?

     

     

    • lbendlin's avatar
      lbendlin
      Super User

      In the Employees table:

       

      [Email Address]=USERPRINCIPALNAME()

      • Anonymous's avatar
        Anonymous
        Not applicable

        Right but I need everyone from the contract to be able to see it with many emails being associated with the same contract. I guess i am missing something.