I have custom code inside of a SSRS report that needs to get the current user. e.g.
Dim myPrincipal As New System.Security.Principal.WindowsPrincipal
(System.Security.Principal.WindowsIdentity.GetCurrent())
I would have expected GetCurrent() to return the principal of the user that was accessing the report; however, it gives me the principal of "NT AUTHORITY\NETWORK SERVICE". Does anyone know how to get ReportServer to run as the user running the report? I checked both web.config, and they both indicate Windows Authentication and Impersonate=True.
Ok, I figured it out. I just used
System.Threading.Thread.CurrentPrincipal.Identity
instead of
WindowsIdentity.GetCurrent()
This doesn't work when I'm am previewing the report locally i.e.
Thread.CurrentPrincipal.Identity.Name //returns an empty string when previewing locally
but it works fine after I deploy to a server.