报表查看器在通过域名访问时返回 rsAccessDenied

问题描述 投票:0回答:1

我正在构建一个包含 SQL Server 报告查看器的 ASP .NET Web 应用程序。查看器由 Microsoft.ReportingServices.ReportViewerControl.WebForms 包提供。

当使用本地主机连接时,报告显示正常,但当使用域名(www.example.com)连接时,会出现以下文本:

授予用户“hardcodeddomain\hardcodeduser”的权限不足以执行此操作。 (rsAccessDenied)

我不知道为什么使用不同的主机名会改变结果,但应用程序非常简单。

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"));
        }
    }
}

有人知道为什么会这样吗?

c# asp.net reporting-services webforms
1个回答
0
投票
  1. 转到 SQL Server Reporting Services 门户网站(对我来说是 http://localhost/reports/browse)
  2. 转到“管理文件夹”
  3. 点击“添加组或用户”
  4. 输入硬编码用户的用户名
  5. 检查所有权限(或您的用例所需的权限)
  6. 点击确定

出于某种原因,这会影响用户是否可以通过域名访问报告。我认为“站点设置”中的安全性就足够了,但显然不够!

© www.soinside.com 2019 - 2024. All rights reserved.