Reporting Services 2008 - 401: Unauthorized

10,292

OK, I've finally had to change the code to:

rs.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

and it worked. Probably there's another solution but I couldn't find it out.

Share:
10,292
Diego Jancic
Author by

Diego Jancic

Software and solution developer. I focus mainly on development of high performance and scalable web applications. Technologies: C#, .NET, SQL Server, MongoDB, Javascript & jQuery. I have a Bachelor's degree in Finance, which gave me the knowleadge to evaluate projects and perform the economic projections needed to create successful businesses. Specialties: Software development, IT, financial analyst

Updated on June 04, 2022

Comments

  • Diego Jancic
    Diego Jancic almost 2 years

    I've an application that connects to Reporting Services in SQL Server 2008 R2.

    The error is the following:

    System.Net.WebException: The request failed with HTTP status 401: Unauthorized.
    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse
       (SoapClientMessage message, WebResponse response, Stream responseStream, 
        Boolean asyncCall)
    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke
       (String methodName, Object[] parameters)
    at Microsoft.SqlServer.ReportingServices2005.Execution.ReportExecutionService.LoadReport
       (String Report, String HistoryID) 
    

    The application is running in production fine in 2 different customers, so it's not a codeing issue.

    I'm trying to install it now on a customer's server, which is using AD. The SQL Server and the IIS is all in the same machine though, so I don't really care about AD.

    It runs if I run IE as Administrator, but it doesn't work with other users. The ASP.NET app is connecting to SSRS using a user created in the local machine (called ReportingServicesUser), member of the ReportingServicesUser group.

    Things I've tried:

    • Adding ReportingServicesUser to the Site Settings in the RS website (did the same for Network Service, IUSR, the Authenticated Users group, Local Service, etc)
    • Adding ReportingServicesUser to the folder permissions in the RS website (did the same for Network Service, IUSR, the Authenticated Users group, Local Service, etc)
    • Added permissions for that users to the databases (app database and RS related dbs)
    • Added NTFS permissions to the RS folders (I will double check though).
    • Connecting to the RS using http://localhost, http://computername and http://domain.com

    For reference, the code is this (simplified version):

    var service = new ReportExecutionService();
    service.Credentials = new NetworkCredential("ReportingServicesUser", "password");
    service.Url = "http://computername:90/ReportServer/ReportExecution2005.asmx";
    
    service.ExecutionHeaderValue = new ExecutionHeader();
    
    var execInfo = new ExecutionInfo();
    execInfo = service.LoadReport("path-to-the-report", null);
    ===>  Here it throws the exception
    

    I've read a lot of posts and pages about this but I cannot get an answer that works for me.