Secured Reports
Hello,
We have 100 sellers. All their sales stored in single database.
I need to build report where any seller can view his sales statistic. User should not see statistic for another sellers, only his own.
Can I build this report in Reporting Services?
July 18th, 2012 5:37am
Hi Alexander,
Yes, you very well can do this with SSRS.
From the top of my head, I can think of two approaches to achieving this:
1. Based on the User Accessing the reports:
Let's assume that you have two sellers, S1 and S2 in your database table. Corresponding to each of the Sellers, you would have an associated user, U1 for S1 and U2 for S2. U1 has a domain account as domain\U1 and U2 has domain\U2. Now you could write your
query in such a way that it returns only those records corresponding to the user running the report. In other words, you could parameterize the query on the logged in user or the one running the report. SSRS provides you with the User collection from which
you can get the user who is running the report:
=User!UserID
You could then connect this to your query as
SELECT * FROM Sellers
WHERE Seller_Domain_Account = @User
-- @User is the User!UserID
This is going to ensure that you return only those records pertaining to the logged in user. However, the question with this approach is if you have the accounts of all the users who access to your reports. If yes, I think this is quite an easy way to go.
2. Linked Reports:
You could create multiple versions of the same report and set a different parameter value for each of the reports. So if you have two sellers, you would set up two copies of the report, and each of these could be set with their own default parameters. Here
is a very good link that talks about this approach and similar to your requirement:
http://www.mssqltips.com/sqlservertip/2308/sql-server-reporting-services-linked-reports-example/
Let me know if you need more info.
HTH.
Cheers,
IceQB
Please mark correct answers :)
Free Windows Admin Tool Kit Click here and download it now
July 18th, 2012 6:53am