SSRS Column Hide based on User Login.

  • HI,

    I need to create a report in which I need to hide the column data base on who userid.

    for example if Manager want to see the report then manager can see all the column in report but if Supervisor want to view the same report then he can only see few column.

    Any suggestion or help would be appreciated ,

    Thanks

  • vax09 (9/19/2013) I need to create a report in which I need to hide the column data base on who userid.

    for example if Manager want to see the report then manager can see all the column in report but if Supervisor want to view the same report then he can only see few column.

    ...

    You can easily trigger the visibility property of any table via an expression. In this case the User.UserID

    You have to be aware though, that this is not completely secure. If the user can use a data renderer (xml or csv), all data will be included - they do not honor visibility.

    If you cannot risk that, you need to run two different queries, again parameterized by the expression UserID and then return an empty column for certain users.

    If you combine both approaches you have the flexibility in the presentation as well as the flexibility in the backend, where you can create tables with groups of people who see certain data and others not, which you can join to a DataSet when needed.

    Andreas

    ---------------------------------------------------
    MVP SQL Server
    Microsoft Certified Master SQL Server 2008
    Microsoft Certified Solutions Master Data Platform, SQL Server 2012
    www.insidesql.org/blogs/andreaswolter
    www.andreas-wolter.com

  • Hi. the only effective way to do this is:

    1. Create a VIEW of the table for the low-security user with the columns that s/he may see.

    2. Set up two database roles: Let's call one GRUNTS and the other MANAGERS.

    3. Give the Supervisor the GRUNTS role and the Manager the MANAGERS role.

    4. REMOVE db_datareader from both users

    5. GRANT SELECT on all table names to MANAGERS. Example code:

    select

    'GRANT SELECT ON ' + [name] + ' to MANAGERS;'

    as Execute_this

    from sys.tables;

    Run the outputs in a new SSMS window.

    6. GRANT SELECT on all table names EXCEPT those you want to limit to GRUNTS. Example code:

    select

    'GRANT SELECT ON ' + [name] + ' to GRUNTS;' as Execute_this

    from sys.tables

    where [name] not in ('notallowed1','notallowed2',etc.);

    Run the outputs in a new SSMS window.

    7. DENY on all table names you want to limit to GRUNTS. Example code:

    select

    'DENY SELECT, INSERT,UPDATE,DELETE ON ' + [name] + ' to GRUNTS;' as Execute_this

    from sys.tables

    where [name] in ('notallowed1','notallowed2',etc.);

    8. GRANT on all views you want to allow to GRUNTS. Example code:

    select

    GRANT SELECT ON ' + [name] + ' to GRUNTS;' as Execute_this

    from sys.views

    where [name] in ('allowed1','allowed2',etc.);

    Run the outputs in a new SSMS window.

    And you should have yourself covered.

    Thanks

    John.

  • Ok

    I guess instead of Tables you want to give permissions on the views that you mentioned.

    You might just as well put them into 2 different schemas.. keeps the permissions on schema-level - and just 1-2 permissions instead of one per object and grantee

    Andreas

    ---------------------------------------------------
    MVP SQL Server
    Microsoft Certified Master SQL Server 2008
    Microsoft Certified Solutions Master Data Platform, SQL Server 2012
    www.insidesql.org/blogs/andreaswolter
    www.andreas-wolter.com

  • Andreas.Wolter (9/24/2013)


    Ok

    I guess instead of Tables you want to give permissions on the views that you mentioned.

    You might just as well put them into 2 different schemas.. keeps the permissions on schema-level - and just 1-2 permissions instead of one per object and grantee

    True, that works. However, then you need to develop views for many tables if they reside in the MANAGERS schema. Just looking at the object counts. also, there are many who don't like to work with schemas, and prefer to use only dbo.

    That's why I went with the roles-to-objects approach.

    Thanks

    John.

  • johntam (9/24/2013)


    Andreas.Wolter (9/24/2013)


    Ok

    I guess instead of Tables you want to give permissions on the views that you mentioned.

    You might just as well put them into 2 different schemas.. keeps the permissions on schema-level - and just 1-2 permissions instead of one per object and grantee

    True, that works. However, then you need to develop views for many tables if they reside in the MANAGERS schema. Just looking at the object counts. also, there are many who don't like to work with schemas, and prefer to use only dbo.

    well.. those then should learn about the advantages of schemas and why it's (usually) bad practice to just use dbo. SQL 2000 is over...

    Andreas

    ---------------------------------------------------
    MVP SQL Server
    Microsoft Certified Master SQL Server 2008
    Microsoft Certified Solutions Master Data Platform, SQL Server 2012
    www.insidesql.org/blogs/andreaswolter
    www.andreas-wolter.com

Viewing 6 posts - 1 through 5 (of 5 total)

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