Monday, March 26, 2012

ReportViewer (ASP.NET) and Forms Authentication

I have successfully implemented forms authentication in RS. It works great to navigate to https://myserver/Reports. I get redirected to the login-page etc. It also works great to use the ReportViewer from within my WinForms app, using the

reportViewer.ServerReport.ReportServerCredentials.SetFormsCredentials

method. I'm also able to communicate with RS through it's web services by first calling the 'LogonUser' method. However, to get that to work I had to inherit the ReportExecutionService for the cookie-handling to work.

Now over to my problem (the only thing so far I haven't got working). I'm trying to use a ReportViewer on an ASP.net web page to access the reports. I have understood that 'SetFormsCredentials' is not avaliable here. Instead, as far as I have understood, I should implement my own IReportServerCredentials . The critical method there I guess is

GetFormsCredentials(out Cookie authCookie, out string formsUser, out string formsPassword, out string formsAuthority)

, am I right?

It's here my problem starts. The examples I have seen haven't implemented this method since they use other types of authentication. So, I would need an example of what to fill that method with...

Regards Andreas

Is there at least some documentation where I can read about this...?

(Can't find any examples on it...)

|||

After some more testing, I'm now able to render a report. This is possible if I implement the method like this:

public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)

{

authCookie = null;

user = "validUser";

password = "validPassword";

authority = "";

return true;

}

But from what I can understand this method should be returning a cookie...

And I have done testings with the method described here: http://blogs.msdn.com/bimusings/archive/2005/11/04/489100.aspx, but if I return something else then null as cookie-Value, I get an exception like this:

Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'.....

So, if I return null as cookie-value I'm able to render the report, but I run into trouble when clicking on a link in the report that navigates to another report. The report isn't rendered, instead the message

  • Execution 'lvzt54q0lq1nrbjjmmubr02b' cannot be found
    is shown.

    Any kind of help here would be of great value!

    Regards Andreas

  • No comments:

    Post a Comment