RLS Filters

  • Comments posted to this topic are about the item RLS Filters

  • This was removed by the editor as SPAM

  • I think there's a typo:

    CREATE SECURITY POLICY rls_CustomerFilter

    ADD FILTER PREDICATE dbo.rls_customer_check(customerid)

    ON dbo.CustomerAccessList;

    GO

    "customerid" instead of "username" passed as parameter to the inline function.

    Anyway, the typo doesn't change the correct answer.

  • CREATE SECURITY POLICY rls_CustomerFilter

    ADD FILTER PREDICATE dbo.rls_customer_check(customerid)

    ON dbo.CustomerAccessList;

    GO

    the above is not included "WITH (STATE=ON)". I thought security policy is not enabled yet and insert succeeds.

  • I don't understand how this can work, even if you do pass 'bsmith' rather than 5 into the check function (can '5' be cast as a sysname, anyway?).

    The function returns 1 if the supplied name matches the value returned by USER_NAME(). If I run that on my system, I get 'dbo', which according to books online is what you get for a user that is a member of the sysadmin role.

    Even if USER_NAME() returned 'bsmith' for that user, what does this achieve? It appears to have the effect of allowing users to only give themselves access to the specified customer. But it does not stop anybody from doing so, does it?

    Am I missing something?

  • Bob JH Cullen (3/17/2016)


    I don't understand how this can work, even if you do pass 'bsmith' rather than 5 into the check function (can '5' be cast as a sysname, anyway?).

    The function returns 1 if the supplied name matches the value returned by USER_NAME(). If I run that on my system, I get 'dbo', which according to books online is what you get for a user that is a member of the sysadmin role.

    Even if USER_NAME() returned 'bsmith' for that user, what does this achieve? It appears to have the effect of allowing users to only give themselves access to the specified customer. But it does not stop anybody from doing so, does it?

    Am I missing something?

    As from BOL, FILTER PREDICATE is active only on READ and not in WRITE. For "insert" o "update" you should use BLOCK.

  • Correct, you need a BLOCK predicate to stop writes.

    Sorry for the typo, I'll correct things.

  • Appreciate the question Steve.

  • Thank you for the question.

  • Interesting question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply