问题描述
|
我是SSRS的新手,我已经开发了一些在网络框架中运行SSRS的报告。一切在我的本地PC上都可以100%工作。但是现在我想将报告和新页面移至Web服务器。我设法使其在Web服务器上运行,但是由于某些原因,我认为必须在SQL Server 2008 SSRS上进行配置设置,每次运行该报告时,它都要求我为数据源指定用户名和密码。
该报告在Web框架中运行,该页面是使用ASP.NET开发的,我将在页面上选择的参数传递给该报告以生成该报告。
我将在此处附上图片以说明我所得到的。我想念的东西可能真的很愚蠢。但是任何帮助将不胜感激。
解决方法
凭据与DataSource有关,我与ssrs一起工作了一点,我记得您可以在设置DataSource时设置身份验证的类型。
在这里您可以找到有用的信息。
, 我一直在我的项目上使用此代码,并且可以正常工作。首先,您必须创建实现IReportServerCredentials的自定义凭据类
界面。
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
}