Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SSRS Column Hide based on User Login.


SSRS Column Hide based on User Login.

Author
Message
vax09
vax09
SSC Rookie
SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)SSC Rookie (27 reputation)

Group: General Forum Members
Points: 27 Visits: 370
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
Andreas.Wolter
Andreas.Wolter
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 1056
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
SQLBlimp
SQLBlimp
SSC Eights!
SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)

Group: General Forum Members
Points: 828 Visits: 495
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.
Andreas.Wolter
Andreas.Wolter
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 1056
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
SQLBlimp
SQLBlimp
SSC Eights!
SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)SSC Eights! (828 reputation)

Group: General Forum Members
Points: 828 Visits: 495
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.
Andreas.Wolter
Andreas.Wolter
SSC-Enthusiastic
SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)SSC-Enthusiastic (155 reputation)

Group: General Forum Members
Points: 155 Visits: 1056
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search