locked
The request failed with HTTP status 401: Unauthorized. RRS feed

  • Question

  • User-466406294 posted

    Hi all,

    i've two systems one hosts a SQL Server 2008 Server and another is my local system in which i've developed a website. both systems are registered under an active diretory domain, which is also another system. using reporting services i created a report in the sql server that calls a stored proceedure which requires a single parameter to generate a result.

    now inorder to display the report on the website i created a ReportServerCredentials class that implements an IReportServerCredentials show below:

    Imports Microsoft.VisualBasic
    Imports Microsoft.Reporting.WebForms
    Imports System.Security.Principal
    
    Public Class ReportVererCredentials
        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 New Net.NetworkCredential(_userName, _password, _domain)
            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
    
            authCookie = Nothing
            userName = Nothing
            password = Nothing
            authority = Nothing
            Return False
        End Function
    
    End Class

    To use this class i wrote the following code in the Page_Load event

    If Not Page.IsPostBack Then
                ReportViewer1.ProcessingMode = ProcessingMode.Remote
                'ReportViewer1.ShowCredentialPrompts = True
    
    
                ReportViewer1.ServerReport.ReportServerCredentials = New ReportVererCredentials("xxx", "xxxx", "xxxx")
                ReportViewer1.ServerReport.ReportServerUrl = New Uri("http://xxx/ReportServer")
    
                ReportViewer1.ServerReport.ReportPath = "/Test_Reports/Test_Report"
                'ReportViewer1.ShowParameterPrompts = False
                'ReportViewer1.ShowPrintButton = True
                Dim invoiceno(1) As ReportParameter
                paramVar1 = New ReportParameter() {New ReportParameter("paramName", Request.QueryString("paramValue"))}
                ReportViewer1.ServerReport.SetParameters(paramVar1)
                ReportViewer1.ServerReport.Refresh()
            End If

    When i run this the page displays the reportviewer and the loading animation for a while and stops and the reportviewer is empty. When i run the website on debug mode only it stops on the line:

    ReportViewer1.ServerReport.SetParameters(paramVar1)

    and then show the error message "The request failed with HTTP status 401: Unauthorized"

    i know this question had been asked many times and there are many solutions and worked for many. i've tried all the solutions that i could find out there and still having the error. I've tried the following solutions

    1- included <identity impersonate="true" /> under <system.web> tag in web.config file

    2- changed the build target flatform to x86 as some one suggested that selecting "AnyCPU" might create that problem because the SQL Server 2008 is a VM on a 64bit platform (ESX Server).

    3- Verified that my SQL server is displaying the report when i access it directly throught a web browser.

    4- I added browser role to the user from the report manager site

    5- On the line

    ReportViewer1.ServerReport.ReportServerCredentials = New ReportVererCredentials("xxx", "xxxx", "xxx")

    i'm not sure whether to use active directory domain credentials or sql server credentials. So i tested using both and still the same error is displayed.

    i know i'm either missing something or doing something wrong... please help

    thanx in advance

    Thursday, November 24, 2011 1:43 AM

All replies

  • User-466406294 posted

    anyone out there who could help me... crying for HELP here... please  help...

    Saturday, November 26, 2011 10:02 AM
  • User-8475372 posted

    Ok. As you have described, you have given browser role to the user in reporting manager site settings. 

    1. Try giving full access to that user, also make sure you are giving the access to the required folder where you hosted your reports. (Or try by giving EVERYONE as role)

    2. If you are using Reporting Service (Webservice or WSDL), please verify whether it is pointing to the same server asmx files.

    Monday, November 28, 2011 1:10 AM