views:

1017

answers:

4

I have set up SSRS on my localhost, and used BIDS to create a couple of reports on them. They access data from the same SQL Server where the SSRS is deployed, and when I preview them they run fine. Then I deployed them to my localhost SSRS and accessed them via the ReportManager web interface, again they ran just fine. Finally I deployed them to my hosting provider's SSRS. Same deal; good data connectivity and it looks great in the ReportManager.

The first time I access them through the ReportManager on either system, it demands my username and password, which on my laptop is just my account logon and password. For my hosting provider it's my account logon for them.

My problem is when I try to display a report using the ReportViewer control in ASP.Net. Very often, when it tries to render I get a "Bad Logon" or "401: Unauthorized" instead of my report. After a lot of reading and pondering, I believe the problem is that I need to log on not to the SQL Server, but to the website (web service?) where my reports are exposed. Right now if I don't provide any credentials at all, I can get my local reports in the ReportViewer (usually). However, when I deploy the reports to a remote server, this doesn't work anymore.

After some research I created a class that implements IReportServerCredentials and tried using it to pass in the username and password, but this doesn't appear to work. And it was confusing me whether these credentials are supposed to be for the data source or for the web service.

If anyone could clue me in on how to get the ReportViewer to log in to the SSRS web service, I'd much appreciate it.

A: 

It's always challenging to debug authentication issues remotely, but you might able to solve your problem by enabling impersonation on your AppPool. That way, when a user is logged-in, IIS would be able to connect to SQL Server as your user.

Another approach might be to use SQL Authentication; unfortunately, the details depend on how you have things hooked up.

RickNZ
I definitely would prefer to use SQL Authentication; mainly because I've never understood how Windows Authentication does what it does. And because on web app's there isn't a network logon involved. I'm going to read up on impersonation.
Mike at KBS
+1  A: 

Assuming that you have set the ProcessingMode="Remote" attirbute on the viewer, then you probably have an authentication issue. When using the report viewer in remote mode, the report is executed on SSRS by the account ASP.Net is running under. This account must have access to the reporting server and to the report you want to run. What is probably happening is that ASP.Net is running under an account that does not have access to SSRS.

If you want to be able to set the credentials for the report viewer, take a look at this thread for a solution and sample code.

TskTsk
As a matter of fact, I got an error just like that when I deployed to another staging location, saying the NT Account I was using did not have the privileges to perform that action. Understanding impersonation and what account my applications run under is something I need to focus on more. In the end today, I was able to get this thing to run by adding a role for "BUILTIN\Users" of "Browser". It works, but I'm not crazy about it as I think it basically means the report is now not locked down at all. I'm going to continue to pursue the answers I get here.
Mike at KBS
In the end, I finally figured it out by examining the credentials class I built more carefully, comparing it to sample code I knew worked. It turned out that I was returning "True" from my GetFormsCredentials() method. Since I never intended to use Forms Authentication I should have returned "False." All the "out" param's to that method were being set to NULL so the authentication was never being done correctly, and I didn't realize it.
Mike at KBS
Awesome. We ran into the same issues when we were trying to integrate SSRS with our web app. In the end we were able to get the permissions just right, but it was painful.
TskTsk
A: 

Please check the two versions mentioned below for better understanding. Windows authentication: http://praveenbattula.blogspot.com/2010/01/report-viewer-control-authentication.html

Please let me know, if you have any questions.

thanks -Praveen.

A: 

For authenticating using Forms authentication: http://praveenbattula.blogspot.com/2010/01/report-viewer-control-authentication_16.html