2010-06-22 27 views
0

我有一個SSRS報告中需要獲取當前用戶的自定義代碼。例如SSRS WindowsIdentity.GetCurrent()給我NT AUTHORITY NETWORK SERVICE

Dim myPrincipal As New System.Security.Principal.WindowsPrincipal 
    (System.Security.Principal.WindowsIdentity.GetCurrent()) 

我希望GetCurrent()返回正在訪問報表的用戶的主體;但是,它給了我「NT AUTHORITY \ NETWORK SERVICE」的校長。有誰知道如何讓ReportServer以運行報表的用戶身份運行?我檢查了兩個web.config,它們都指示Windows身份驗證和Impersonate = True。

回答

2

好吧,我想通了。我只是用

System.Threading.Thread.CurrentPrincipal.Identity 

,而不是

WindowsIdentity.GetCurrent() 

,當我正在預覽本地即報告

Thread.CurrentPrincipal.Identity.Name //returns an empty string when previewing locally 

這並不工作,但之後我部署到它工作正常服務器。

相關問題