Results 1 to 6 of 6

Thread: [RESOLVED] The request failed with HTTP status 401: Unauthorized

  1. #1

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Resolved [RESOLVED] The request failed with HTTP status 401: Unauthorized

    I have the following error:
    "The request failed with HTTP status 401: Unauthorized"

    When i try to use an web site (hosted in IIS on Machine1) call a reporting service report using reportviewer (hosted in SQL Server in Machine2)

    I already add Networking service permissions to SSRS in Machine2, but the error continues...

    Any help is appreciated...
    Thx

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: The request failed with HTTP status 401: Unauthorized

    Hello,

    Personally, I would be creating another user, a service account, and use that to access Reporting Services, rather than using the Network Services user.

    When you said this:

    I already add Networking service permissions to SSRS in Machine2, but the error continues...
    Did you mean you have added "Machine1\Network Services" to SSRS on Machine2? And have you made sure that it is "Machine1\Network Services" that is running the application pool in IIS that is hosting your website?

    Gary

  3. #3

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: The request failed with HTTP status 401: Unauthorized

    Quote Originally Posted by gep13 View Post
    Hello,

    Personally, I would be creating another user, a service account, and use that to access Reporting Services, rather than using the Network Services user.

    When you said this:



    Did you mean you have added "Machine1\Network Services" to SSRS on Machine2? And have you made sure that it is "Machine1\Network Services" that is running the application pool in IIS that is hosting your website?

    Gary
    I added Machine2\Network Services (local) to the report, inside SSRS Report Manager

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: The request failed with HTTP status 401: Unauthorized

    Hello,

    But if the request from for the report is being initiated by Machine1\Network Services (assuming this is hte identity of the person that is running the application pool), then this isn't the same user as Machine2\Network Services.

    Gary

  5. #5

    Thread Starter
    Frenzied Member zuperman's Avatar
    Join Date
    Dec 2000
    Location
    Portugal
    Posts
    1,033

    Re: The request failed with HTTP status 401: Unauthorized

    Made some research... and i found a solution...

    Add a class to your web site
    Code:
    Imports Microsoft.Reporting.WebForms
    Imports System.Net
    
    Public Class ReportServerCredentials
        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 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
    
        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 NetworkCredential(_username, _password, _domain)
            End Get
        End Property
    
    End Class
    Then, in the page load event of your aspx, specify the credentials to the server

    Code:
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not IsPostBack Then
                Me.ReportViewer1.ServerReport.ReportServerCredentials = New ReportServerCredentials("user", "pass", "domain")
                Me.ReportViewer1.ServerReport.Refresh()
            End If
        End Sub
    Thx

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] The request failed with HTTP status 401: Unauthorized

    Interesting, I didn't think you would have had to go to that length. I thought you would have only had to turn on impersonation on your site, or change the identity of the running process.

    Good to know thought I guess, thanks for posting!

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width