SSRS WindowsIdentity.GetCurrent() giving me NT AUTHORITY\NETWORK SERVICE

坚强是说给别人听的谎言 提交于 2019-12-12 02:59:29

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3095449/ssrs-windowsidentity-getcurrent-giving-me-nt-authority-network-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!