SSRS - 登录错误

时间:2011-05-30 10:34:12

标签: c# asp.net ssrs-2008 reporting-services

我是SSRS的新手,我在网络框架中开发了一些运行SSRS的报告。一切都在我的本地PC上100%工作。但现在我想将报告和新页面移动到Web服务器。我设法让它在Web服务器上运行但由于某种原因我认为必须在SQL Server 2008 SSRS上进行配置设置,每次运行报告时它都要求我指定数据源的用户名和密码。

报告在网页框架中运行,页面是在ASP.NET中开发的,我将页面上选择的参数传递给报告以生成报告。

我会在这里附上一张图片来说明我得到了什么。我错过了可能是非常愚蠢的事情。但是,任何帮助将不胜感激 SSRS Error on webpage

2 个答案:

答案 0 :(得分:1)

凭证是关于DataSource的,我对ssrs有点工作,我记得你可以在设置DataSource时设置身份验证的类型。

Here您可以找到有用的信息。

答案 1 :(得分:0)

我一直在我的项目中使用此代码并且它有效。首先,您必须创建实现IReportServerCredentials的自定义凭证类  intefrace。

public class ReportServerCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{
    #region private members

    private string _username;
    private string _password;
    private string _domain;

    #endregion

    #region Constructor


    /// <summary>
    /// Initializes itself with ReportServerUsername, ReportServerPassword and ReportServerDomain settings from web.config 
    /// </summary>
    public ReportServerCredentials()
    {
        this._username = "USERNAME";
        this._password = "PASSWORD";
        this._domain = ""; // set if its domain server
    }

    public ReportServerCredentials(string username, string password, string domain)
    {
        this._username = username;
        this._password = password;
        this._domain = domain;
    }

    #endregion

    #region IReportServerCredentials Members

    public bool GetFormsCredentials(out System.Net.Cookie authCookie, out string userName, out string password, out string authority)
    {
        authCookie = null;
        userName = password = authority = null;
        return false;
    }

    public System.Security.Principal.WindowsIdentity ImpersonationUser
    {
        get { return null; }
    }

    /// <summary>
    /// Creates a System.Net.NetworkCredential object with the specified username, password and domain.
    /// </summary>
    public System.Net.ICredentials NetworkCredentials
    {
        get { return new System.Net.NetworkCredential(_username, _password, _domain); }
    }

    #endregion
}

在显示凭据之前将凭据提供给报告。

ReportParameter[] param = new ReportParameter[0];

protected void Page_Load(object sender, EventArgs e)
{
    this.ReportViewer1.Reset();
    this.ReportViewer1.ServerReport.ReportServerUrl =
            new System.Uri(ConfigurationManager.AppSettings["ReportServerUrl"]); // reads report server url from config file
    IReportServerCredentials customCred =
            new ReportServerCredentials(); //reads the username, password and domain from web.config
    this.ReportViewer1.ServerReport.ReportServerCredentials = customCred;

    this.ReportViewer1.ServerReport.ReportPath =
        "/PATH_TO_SOME_REPORT"; // TODO: Put some real report path

    this.ReportViewer1.ServerReport.SetParameters(param); // this will initialize report
}