none
Web ReportViewer fails with SSRS forms athentication RRS feed

  • Question

  • I have sucsessfuly implemented a custom security extension in SSRS 2005, and now we can authenticate using custom forms in reportmanager and reportserver. Now I am trying to use our asp.net web application using the same custom authentication: I call LogonUser in my report server proxy class and get the authentication cookie managed in subsecuent requests from my application; in this way I can browse the contents of the report catalog, show properties, etc. The problem arises when I try to render a report in the web reportviewer.

     

    I implemented the IReportServerCredentials in the class shown below and use it as:

     

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(ConfigurationManager.AppSettings("ReportService2005.ReportService2005"))

    ReportViewer1.ServerReport.ReportPath = Session("ReportPath")

    ReportViewer1.ServerReport.ReportServerCredentials = New ReportViewerCredentials("", "", "")

     

    however I get the error object moved to XXX where XXX is an href to the same page where the ReportViewer is calling on the first place. I follow the code and the IReportServerCredentias is called as it should be, returns the authCookie as the one from the initial LogonUser; also using tcpTrace I see that the cookie is in the request and the response.

     

    I appreciate any ideas and help.

     

     

    IReportServerCredentials  implementation:

     

    <Serializable()> _

    Public Class ReportViewerCredentials

    Implements IReportServerCredentials

    Private _userName As String

    Private _password As String

    Private _domain As String

    Public Sub New(ByVal userName As String, ByVal password As String, ByVal domain As String)

    _userName = userName

    _password = password

    _domain = domain

    End Sub

    Public ReadOnly Property ImpersonationUser() As System.Security.Principal.WindowsIdentity Implements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser

    Get

    Return Nothing

    End Get

    End Property

    Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials

    Get

    Return Nothing

    End Get

    End Property

    Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef userName As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials

    userName = password = authority = Nothing

    Dim cookie As HttpCookie = HttpContext.Current.Request.Cookies("sqlAuthCookie")

    If cookie Is Nothing Then

    HttpContext.Current.Response.Redirect("~Default.aspx")

    End If

    Dim netCookie As New Cookie(cookie.Name, cookie.Value)

    If cookie.Domain Is Nothing Then

    netCookie.Domain = HttpContext.Current.Request.ServerVariables("SERVER_NAME").ToUpper()

    End If

    netCookie.Expires = cookie.Expires

    netCookie.Path = cookie.Path

    netCookie.Secure = cookie.Secure

    authCookie = netCookie

    Return True

    End Function

    End Class

    Wednesday, May 2, 2007 5:02 PM

Answers

  • Hi Mridu,

     

    I did find the solution. I don't remember what I was doing wrong, but my code today is as follows:

     

    Code Block

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(http://localhost/ReportServer/)

    ReportViewer1.ServerReport.ReportPath = Session("spyReporte")

    If IsNothing(ReportViewer1.ServerReport.ReportServerCredentials) Then

    ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials(RESProxy.AuthCookie)

    End If

     

     

    The code for MyReportServerCredentials:

     

    Code Block

    Public Class MyReportServerCredentials

    Implements IReportServerCredentials

    Private m_authCookie As Cookie

     

    Public Sub New(ByVal authCookie As Cookie)

    m_authCookie = authCookie

    End Sub 'New

     

    Public ReadOnly Property ImpersonationUser() As System.Security.Principal.WindowsIdentity Implements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser

    Get

    Return Nothing ' Use default identity.

    End Get

    End Property

     

    Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials

    Get

    Return Nothing ' Not using NetworkCredentials to authenticate.

    End Get

    End Property

     

    Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef user As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials

    authCookie = m_authCookie

    user = password = authority = Nothing

    Return True ' Use forms credentials to authenticate.

    End Function 'GetFormsCredentials

    End Class 'MyReportServerCredentials

     

     

    Please note that in the first block of code I use:

     

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(http://localhost/ReportServer/)

     

    I remember that one of my mistakes was to use the Report Execution Service instead of the Report Server. (

    http://localhost/ReportServer/ReportExecution2005.asmx does not work).

     

    Also note that I pass the Authentication Cookie to the MyReportServerCredentials constructor. This cookie is the one I get when performing the LogonUser, which I suppose you already got.

     

    Hope this helps.

    Wednesday, December 12, 2007 2:13 PM

All replies

  • Anyone please! I'm stuck in here!

     

    Tuesday, May 8, 2007 3:20 PM
  • Hi,

     

    Ya, im also facing the same problem. Have been searching the solution.

    Hope you have found a solution to it.

     

    Mridu

    Wednesday, December 5, 2007 11:26 AM
  • Hi Mridu,

     

    I did find the solution. I don't remember what I was doing wrong, but my code today is as follows:

     

    Code Block

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(http://localhost/ReportServer/)

    ReportViewer1.ServerReport.ReportPath = Session("spyReporte")

    If IsNothing(ReportViewer1.ServerReport.ReportServerCredentials) Then

    ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials(RESProxy.AuthCookie)

    End If

     

     

    The code for MyReportServerCredentials:

     

    Code Block

    Public Class MyReportServerCredentials

    Implements IReportServerCredentials

    Private m_authCookie As Cookie

     

    Public Sub New(ByVal authCookie As Cookie)

    m_authCookie = authCookie

    End Sub 'New

     

    Public ReadOnly Property ImpersonationUser() As System.Security.Principal.WindowsIdentity Implements Microsoft.Reporting.WebForms.IReportServerCredentials.ImpersonationUser

    Get

    Return Nothing ' Use default identity.

    End Get

    End Property

     

    Public ReadOnly Property NetworkCredentials() As System.Net.ICredentials Implements Microsoft.Reporting.WebForms.IReportServerCredentials.NetworkCredentials

    Get

    Return Nothing ' Not using NetworkCredentials to authenticate.

    End Get

    End Property

     

    Public Function GetFormsCredentials(ByRef authCookie As System.Net.Cookie, ByRef user As String, ByRef password As String, ByRef authority As String) As Boolean Implements Microsoft.Reporting.WebForms.IReportServerCredentials.GetFormsCredentials

    authCookie = m_authCookie

    user = password = authority = Nothing

    Return True ' Use forms credentials to authenticate.

    End Function 'GetFormsCredentials

    End Class 'MyReportServerCredentials

     

     

    Please note that in the first block of code I use:

     

    ReportViewer1.ServerReport.ReportServerUrl = New Uri(http://localhost/ReportServer/)

     

    I remember that one of my mistakes was to use the Report Execution Service instead of the Report Server. (

    http://localhost/ReportServer/ReportExecution2005.asmx does not work).

     

    Also note that I pass the Authentication Cookie to the MyReportServerCredentials constructor. This cookie is the one I get when performing the LogonUser, which I suppose you already got.

     

    Hope this helps.

    Wednesday, December 12, 2007 2:13 PM
  • I have been having a similar issue. I have a web application trying to provide seamless integration with SSRS so that reports are made available to the web application to run. To get over the error you mention I had to ensure that the cookiename and machine key specified in my web app web.config matched the the one under ReportServer folder. However now I get a:

     

    The item 'Report Project1/Report' cannot be found.

    (rsItemNotFound)

     

    But I login as the admin and can navigate to the Report via IE via <Server>/ReportServer/Folders.aspx w/o problem. Can anyone shed any light?

     

    Wednesday, December 12, 2007 4:30 PM