0

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

2
  • How was this code running on the server? As a service? As an ASP.NET app? Commented Jun 25, 2011 at 11:42
  • It is an ASP app, the code above is on PageLoad method Commented Jun 25, 2011 at 11:48

1 Answer 1

1

Your comment confirms what i suspected - NT AUTHORITY\NETWORK SERVICE is 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:

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, it's working now. All of the methods worked, the important thing to do was to change the anonymous access to windows authentication. I just hope this change will not affect he rest of my application. Thanks, I really appreciate your help
@Adolfo, cool, if it worked then don't forget to mark it as the answer (click the check mark to the left of the answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.