1

我正在运行一个 .NET MVC 3 Web 应用程序。我正在通过网络表单将报告嵌入到我的网页中。下面是我的 webform 类,它将身份验证凭据传递给报表服务器,并在 reportviewer webform 中显示报表,但我仍然收到拒绝访问错误。有什么建议么?

public partial class Reports : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        reportViewer.ServerReport.ReportServerCredentials = new MyReportServerCredentials();

        //Sets the report server based upon environment
        string reportServer = ConfigurationManager.AppSettings["url-reportServer"].ToString();

        //Sets the report path based upon the environment and the report name based upon which report is selected (variable passed through URL)
        string reportPath = ConfigurationManager.AppSettings["url-reportPath"].ToString() + Request.QueryString["reportName"];

        // Set the processing mode for the ReportViewer to Remote to read from server
        reportViewer.ProcessingMode = ProcessingMode.Remote;

        ServerReport serverReport = reportViewer.ServerReport;

        // Set the report server URL and report path
        serverReport.ReportServerUrl = new Uri(reportServer);
        serverReport.ReportPath = reportPath;
    }

    [Serializable]
    public sealed class MyReportServerCredentials : IReportServerCredentials
    {
        public WindowsIdentity ImpersonationUser
        {
            get
            {
                // Use the default Windows user.  Credentials will be
                // provided by the NetworkCredentials property.
                return null;
            }
        }

        public ICredentials NetworkCredentials
        {
            get
            {
                // Read the user information from the Web.config file.  
                // By reading the information on demand instead of 
                // storing it, the credentials will not be stored in 
                // session, reducing the vulnerable surface area to the
                // Web.config file, which can be secured with an ACL.

                // User name
                string userName = ConfigurationManager.AppSettings["MyReportViewerUser"];

                if (string.IsNullOrEmpty(userName))
                    throw new Exception("Missing user name from web.config file");

                // Password
                string password = ConfigurationManager.AppSettings["MyReportViewerPassword"];

                if (string.IsNullOrEmpty(password))
                    throw new Exception("Missing password from web.config file");

                // Domain
                string domain = ConfigurationManager.AppSettings["MyReportViewerDomain"];

                if (string.IsNullOrEmpty(domain))
                    throw new Exception("Missing domain from web.config file");

                return new NetworkCredential(userName, password, domain);
            }
        }

        public bool GetFormsCredentials(out Cookie authCookie, out string userName, out string password, out string authority)
        {
            authCookie = null;
            userName = null;
            password = null;
            authority = null;

            // Not using form credentials
            return false;
        }
    }
}
4

1 回答 1

0

一些事情:

  1. 检查报告服务器配置文件在 NTLM 设置之前的身份验证中是否具有 RSWindowsNegotiate。
  2. 启用身份模拟。
  3. 如果两个服务器都无法通信,请设置服务器主体名称和 kerberos 身份验证
于 2013-12-04T20:42:31.857 回答