none
Impersonating with current logged in user in ReportViewer control RRS feed

  • Question

  • I am currently working on a custom asp.net applicaiton which uses reportviewer control to display few reports. Application is running under windows authentication.


    By default reportviewer control runs under ASPNET user account. I want to change it to run under current logged in user account. I changed the Identity impersonation setting in web.config and make it to true.


    Client does not want any change in web.config.


    I came across this property of Report Viewer control.


    Code Snippet
    ReportViewer1.ServerReport.ReportServerCredentials.ImpersonationUser

     

     


    Now my question is can I use the above prpoerty of reportviewer control to impersonate with current logged in user so that reportviewer control runs under current logged in uesr's identity?


    I appreciate your help.


    Best Regards

     

    Tuesday, March 18, 2008 2:28 PM

Answers

  • By default, the ReportViewer control will connect to the report server as the thread user.  If you don't turn on impersonation in ASP.Net, then the thread user will be the ASPNet user, by default.  I don't believe ASP.Net exposes the authenticated user to the application if impersonation is not turned on.

     

    If you have another way to get the credentials or an impersonation token for the authenticated user, then implementing IReportServerCredentials and returning the WindowsIdentity for this property will do what you want.

    Wednesday, March 26, 2008 9:23 PM
    Moderator

All replies

  • By default, the ReportViewer control will connect to the report server as the thread user.  If you don't turn on impersonation in ASP.Net, then the thread user will be the ASPNet user, by default.  I don't believe ASP.Net exposes the authenticated user to the application if impersonation is not turned on.

     

    If you have another way to get the credentials or an impersonation token for the authenticated user, then implementing IReportServerCredentials and returning the WindowsIdentity for this property will do what you want.

    Wednesday, March 26, 2008 9:23 PM
    Moderator
  •  

    Thanks Brian.

     

    That helps

     

    Regards

    Thursday, March 27, 2008 2:09 AM
  • I realize this was quite some time ago, however . . .

    I have not figured out how to use the impersonate with the  IReportServerCredentials. 

    I have a web form that has a report viewer.  I have a class for the IReport-etc.

    I Impersonate to true in my web.config.

    However, when I watch the values I attempt to plug into the Report Viewer, the value is nothing.

    If I do not use the IReort-etc and attempt to put a value in the Report Viewer credentials, then the value for the user is me on my machine and when moved to the server it is indeed the thread user.

    all the examples I have seen on forums show how to use IReport-etc by plugging in a value from a log in control, etc or by creating a user for the Report server and plug that value into the IReport-etc.

    However, since different people have access to different reports - I need to pass the user to the server.

    Well, actually, when I figure how to return info from the server etc. what I really need to do is build a menu on the web page that will display the reports the logged in user can see. 

    However, I thought I would learn how to manage the access to the report server first.

    d.s.l.

     

    Tuesday, August 2, 2011 1:09 PM