I am trying to pass the loged in username from my dot net application to Report Services. This is my code:
string usern = WindowsIdentity.GetCurrent().Name.ToString();
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl =
new Uri(@"http://myserver/reportServer/");
ReportViewer1.ServerReport.ReportPath = @"/path/subpath/reportName";
ReportParameter[] rp = new ReportParameter[1];
rp[0] = new ReportParameter("paramTest", usern);
ReportViewer1.ServerReport.SetParameters(rp);
ReportViewer1.ServerReport.Refresh();
When I run it locally, everything works fine, I can see my username on the parameters textbox. Running it on server, I got “NT AUTHORITY\NETWORK SERVICE” instead of my username.
Any ideas? Thanks in advance
Your comment confirms what i suspected –
NT AUTHORITY\NETWORK SERVICEis your windows identity on the server – it is the identity the application pool is running as.Here are three links that may help you to get the name of the user of your application if you are using Windows authentication: