Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SSRS Column Hide based on User Login. Expand / Collapse
Author
Message
Posted Thursday, September 19, 2013 12:07 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, October 8, 2014 11:55 AM
Points: 27, Visits: 347
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

Post #1496537
Posted Thursday, September 19, 2013 12:43 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 6:14 AM
Points: 153, Visits: 980
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
Post #1496554
Posted Tuesday, September 24, 2013 10:18 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 11:10 AM
Points: 707, Visits: 333
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.
Post #1497961
Posted Tuesday, September 24, 2013 10:37 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 6:14 AM
Points: 153, Visits: 980
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
Post #1497973
Posted Tuesday, September 24, 2013 10:40 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 11:10 AM
Points: 707, Visits: 333
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.
Post #1497977
Posted Tuesday, September 24, 2013 11:08 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 6:14 AM
Points: 153, Visits: 980
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
Post #1497987
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse