locked
SSRS + get current logged in user to be used as parameter RRS feed

  • Question

  • Hi,

    We are using SSRS 2005 + sql server 2005. We deploy our reports to report server and use report manager (servername/Reports) to launch SSRS reports. Our users use this link to go to the reports and navigate from there to particular reports.

    Right now we are restricting users based on their roles from accessing reports. We got new requirement where we need to know the current logged in username. We have couple of dropdowns, say account, date dropdown. we need to filter account dropdown based on current user logged in. All users won't have access to all the accounts. Based on user name, we need to filter account dropdown and then give user with list of accounts which he choses to view the reports.

    Is it possible to do this. we are not using report viewer or sharepoint. I appreciate your response.

    Thanks,

    Spunny

    Wednesday, June 23, 2010 2:31 PM

Answers

  • Ther User!UserID property is available for this purpose.  It will always give you the user name of the person who is running the report.

    Hope this helps,

    -Lukasz

     


    Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Janos BerkeMVP Wednesday, June 23, 2010 3:04 PM
    • Marked as answer by Jerry Nee Friday, July 2, 2010 6:10 AM
    Wednesday, June 23, 2010 2:50 PM
  • I have done this with success. I used the current user to filter parameter values for reports based on roles.  It did take a little work to make sure it came through properly (used profiler to catch value passed) but worked great once going. I have not had to modify the reports yet and everyone is on a single domain so I am not sure what other factors would contribute to difficulties.
    • Marked as answer by Jerry Nee Friday, July 2, 2010 6:10 AM
    Wednesday, June 23, 2010 7:47 PM

All replies

  • Ther User!UserID property is available for this purpose.  It will always give you the user name of the person who is running the report.

    Hope this helps,

    -Lukasz

     


    Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Janos BerkeMVP Wednesday, June 23, 2010 3:04 PM
    • Marked as answer by Jerry Nee Friday, July 2, 2010 6:10 AM
    Wednesday, June 23, 2010 2:50 PM
  • Lukas ,

    Does user!userid property will only return Username or Domain\Username ?

    It is Showing Domain\USername .

    Thanks


    Rajkumar Yelugu
    Wednesday, June 23, 2010 3:13 PM
  • I think I tried this once, and it worked fine on my personal development machine, but in production I believe I got the report server name.

    I hope I'm wrong.

     

    Let me know

     

    Douglas

    Wednesday, June 23, 2010 4:51 PM
  • I have done this with success. I used the current user to filter parameter values for reports based on roles.  It did take a little work to make sure it came through properly (used profiler to catch value passed) but worked great once going. I have not had to modify the reports yet and everyone is on a single domain so I am not sure what other factors would contribute to difficulties.
    • Marked as answer by Jerry Nee Friday, July 2, 2010 6:10 AM
    Wednesday, June 23, 2010 7:47 PM
  • The value always shows the full user name of the current user.  So it will include domain\user for windows credentials.  If you built custom security it will show that user name. 

    Hope this helps,

    -Lukasz


    Got a bug or feature request? Tell me about it at http://connect.microsoft.com. This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Shweta Raje Thursday, January 5, 2012 5:14 PM
    • Unproposed as answer by Shweta Raje Thursday, January 5, 2012 5:14 PM
    Thursday, July 8, 2010 7:40 PM
  • Add a parameter for example @username into your dataset. Then in dataset parameters tab add "parameter value":

    =User!UserID
    To remove the domain from the username use this instead:
    =mid(User!UserID , InStr(User!UserID,"\")+1)


    • Proposed as answer by Rubiksmomo Monday, December 28, 2015 1:30 PM
    • Edited by Rubiksmomo Monday, December 28, 2015 1:32 PM Prefix the expressions with "="
    Monday, December 28, 2015 1:29 PM
  • Thanks!
    Wednesday, November 16, 2016 9:48 PM