开发者

SSRS - login error

I am new to SSRS and I have developed a few reports running of SSRS in a web frame. Everything is working 100% on my local PC. But now I want to move the reports and the new page to a web server. I managed to get it running on the web server but for some reason I think has to do the config setting on SQL server 2008 S开发者_如何学JAVASRS, every time I run the report it asked me to specify a username and password for the datasource.

The report run in a web frame, the page was developed in ASP.NET and I pass the paramater selected on the page to the report to generate the report.

I will attache an image here to illustrate what I am getting. It is probably something really silly that I am missing. But any help will be greatly appreciated.

SSRS - login error


The credential is about the DataSource, i've worked a little bit with ssrs and I remember you can set the type of authentication when setting up DataSource.

Here you can find the useful information.


I have been using this code on my project and it works. First you have to create custom credentials class that implements 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
}

Feed the credentials to report before displaying it.

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜