Why does the report viewer control return rsAccessDenied when accessed by domain name?

Laura Bailey 1 Reputation point
2023-04-04T04:46:55.73+00:00

I'm building an ASP .NET web application that contains a viewer for SQL Server reports. The viewer is supplied by the Microsoft.ReportingServices.ReportViewerControl.WebForms package. When connecting using localhost the report appears fine, but when connecting using a domain name (www.example.com) this text appears instead:

The permissions granted to user 'hardcodeddomain\hardcodeduser' are insufficient for performing this operation. (rsAccessDenied)

I don't know why using a different host name changes the result but the application is quite simple.

Reports.aspx

<%@ Page Title="Title" Language="C#" MasterPageFile="~/Site.Master" CodeBehind="Reports.aspx.cs" Inherits="ReportingPortal.WebForms.Reports" %>
<%@ Register TagPrefix="rsweb" Namespace="Microsoft.Reporting.WebForms" Assembly="Microsoft.ReportViewer.WebForms, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <rsweb:ReportViewer Width="100%" ID="ReportViewer" runat="server" ProcessingMode="Remote">
        <ServerReport></ServerReport>
    </rsweb:ReportViewer>
</asp:Content>

Reports.aspx.cs

using System;
using System.Configuration;
using System.Web.UI;
namespace ReportingPortal.WebForms
{
    public partial class Reports : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            ReportViewer.ServerReport.ReportServerCredentials = new ReportServerCredentials();
            ReportViewer.ServerReport.ReportPath = "/example/report/path";
            ReportViewer.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings.Get("ReportServerUrl"));
        }
    }
}

Does anyone know why this is happening?

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,312 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,824 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Laura Bailey 1 Reputation point
    2023-04-04T05:41:38.7+00:00
    1. Go to the SQL Server Reporting Services web portal (for me it was at http://localhost/reports/browse)
    2. Go to "Manage folder"
    3. Click "Add group or user"
    4. Enter the username of the hardcoded user
    5. Check on all the permissions (or the ones required for your use-case)
    6. Click OK

    For some reason this affects if the user can access a report through a domain name or not. I thought the security in "Site settings" would be sufficient but apparently not!

    0 comments No comments

  2. AniyaTang-MSFT 12,326 Reputation points Microsoft Vendor
    2023-04-04T08:14:29.1866667+00:00

    Hi @Laura Bailey I'm glad your problem was solved. Yes, when you grant a user access, you need to assign item-level and system-level roles to the user. Among them, the item-level role first needs to grant access to the root directory of the folder, which is what you call "manage folder->Security", otherwise the user you grant the permission cannot access the folder. For folders under the root directory, you can again set user permissions in detail. For more details, you can refer to this link: https://learn.microsoft.com/en-us/sql/reporting-services/security/grant-user-access-to-a-report-server?view=sql-server-ver16. If the answer is helpful, please click Accept Answer and Up-Vote for the same. If you have any questions, please feel free to let me know. Best regards, Aniya

    0 comments No comments