【问题标题】:SSRS, ReportViewer and ASP.NET Access DeniedSSRS、ReportViewer 和 ASP.NET 访问被拒绝
【发布时间】:2011-04-27 22:54:11
【问题描述】:

我有一个带有 ReportViewer 控件的 ASP.NET 应用程序:

<rsweb:ReportViewer ID="rv" runat="server" ProcessingMode="Remote" 
            ShowParameterPrompts="False"AsyncRendering="true" >
    <ServerReport ReportPath="<My Report>" ReportServerUrl="<Report Server URL>" />
</rsweb:ReportViewer>

报告服务器运行在与我的应用服务器不同的服务器上,因此我在调用报告时传递了凭据:

rv.ServerReport.ReportServerCredentials = New ReportCredentials()
rv.ServerReport.SetParameters(params)
rv.ServerReport.Refresh()

凭证在这个类中:

<Serializable()> _
Public Class ReportCredentials
Implements Microsoft.Reporting.WebForms.IReportServerCredentials


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(AppSettings("ReportUser"), Helpers.GetReportPassword(), AppSettings("ReportDomain"))
    End Get
End Property

结束类

在我的 web.config 文件中,我有 impersonate="true"。

我遇到的问题是大多数用户都会收到此错误:

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

如果我在我的帐户下运行应用程序,然后让他们在他们的帐户下尝试,它就可以工作。我可以通过回收应用程序正在运行的应用程序池来为他们重现错误。如果我让用户成为应用服务器上的本地管理员(就像我一样),那么它将起作用,但显然我不想这样做。关于我做错了什么以及为什么应用程序在我运行一次后突然为他们工作的任何想法?

【问题讨论】:

    标签: asp.net reporting-services reportviewer reportingservices-2005


    【解决方案1】:

    发现问题是访问应用服务器上的 machine.config 文件。由于我在 IIS 中使用模拟和集成身份验证运行,因此该应用程序以登录用户身份运行。显然,在获取 NetworkCredentials 时,会访问 machine.config。由于用户无权访问 machine.config,因此失败。我猜 machine.config 被缓存了,所以这就是为什么在我以自己(管理员)身份运行应用程序之后它工作的原因。我继续向我的用户授予对 machine.config 的读取权限,这已经解决了这个问题。不确定是否有更好的方法。

    【讨论】:

    • 最后我只是关闭了模拟,因为我意识到我不需要它。然后我不必给 machine.config 任何额外的权限
    • 你能告诉你在没有冒充的情况下你是怎么做到的吗?谢谢!
    猜你喜欢
    • 1970-01-01
    • 2020-08-09
    • 2013-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多