Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ipisors
Starting Member
39 Posts |
Posted - 2015-04-22 : 14:52:18
|
I am starting to deploy a number of reports (mostly using SSRS) and mostly using stored procedures ending with select statements. In many cases there is a need to log data to a table so that I can maintain a history of when reports were run, and occasionally what the snapshot data return was. I would also like to log the username (network logged on username) of the person running the report, for a variety of useful reasons. Since the SP runs on the server, is there any way to get the username of the person instantiating the procedure, other than by having them use custom front end applications that handle/pass this info? Is there any way to do this via the SSRS web browser interface? Like pass a parameter to the report, and have it default to the user name using an SSRS expression? |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-04-22 : 17:11:35
|
See what SUSER_NAME() shows for these users. I know for internal users through an IIS app, but perhaps not SSRS, it will show their domain account.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
ipisors
Starting Member
39 Posts |
Posted - 2015-04-22 : 20:19:23
|
Thank you, I am going to try this and report back. |
|
|
ipisors
Starting Member
39 Posts |
Posted - 2015-04-22 : 20:26:11
|
Unfortunately it uses the username for the credentials that I have passed as 'use as windows credentials' and saved into the SSRS report, due to the data source....Guess I should have guessed that one. Until we come up with a better way of deploying our ssrs reports, I may have to do without this piece. Thank you for helping me though. Will remember this function. |
|
|
Kristen
Test
22859 Posts |
Posted - 2015-04-23 : 03:12:32
|
I don't know anything about SSRS, but in our APP we pass the Session ID to our SProcs, and log the Start/End of execution using that. For us the Session ID enables us to determine the user active in that session. Perhaps there is something similar in SSRS that you could use? |
|
|
MichaelJSQL
Constraint Violating Yak Guru
252 Posts |
Posted - 2015-04-23 : 07:57:31
|
If you are using credentials at the data source and can use SUSER_NAME() , which is a great way of getting this information, you could us the built in user id function in SSRS. Add a parameter to your procedure and pass the SSRS user id in and store it before returning the report results. |
|
|
|
|
|
|
|