0

我是SSRS报告世界的新手,并且遇到一些试图连接到我的数据源的问题。将Windows标识传递给SSRS报告自定义数据源

我创建了一个新的数据源具有以下属性

  • 使用嵌入在我的报告
  • 连接类型的连接:Microsoft SQL Server的
  • 连接字符串:[@ConnectionString],其中@ConnectionString是我的报告参数的名称。

在凭证标签

  • 提示凭据(与复选框“用作Windows凭据”未选中)

我使用这个数据源预填充我的报告与可用值下拉控制在DB中。 现在,场景是我要将连接字符串从我的aspx页面传递到SSRS报告查看器。

代码摘录如下:

this.rptViewer.ProcessingMode = ProcessingMode.Remote; 
this.rptViewer.ServerReport.ReportServerUrl = new Uri(reportServerUrl);//https     
this.rptViewer.ServerReport.ReportPath = reportPath; 
// this can have either UserName & Password specified or have IntegratedSecurity=SSPI 
connStrBuildr.ConnectionString = connStr; 
ReportParameter reportParameter = new ReportParameter("ConnectionString", connStrBuildr.ConnectionString, false); 
this.rptViewer.ShowCredentialPrompts = false; 
this.rptViewer.ServerReport.SetParameters(reportParameter);          

if (!connStrBuildr.IntegratedSecurity) { // for SQL Auth 
    this.rptViewer.ServerReport.SetDataSourceCredentials(new List<DataSourceCredentials>() { 
     new DataSourceCredentials() { 
     Name = "Custom_DataSource", 
     UserId = connStrBuildr.UserID, 
     Password = connStrBuildr.Password } }); 
} 
else // for Windows Auth 
    { 
    // Created a new class as per some suggestion on internet, to connect to ReportServer which inturn will pass window identity to SQL Server, 
    // but even this didn't work - had no way to exact password . MIND BLOWING STUFF !! 

    //rptViewer.ServerReport.ReportServerCredentials = new CustomReportCredential(username,password,domain) 

    } 
this.rptViewer.ServerReport.Refresh(); 

我的要求是 如果我的连接字符串的用户名和指定的密码,那么应该使用与SQL(Custom_DataSource)连接。

如果指定了IntegratedSecurity = SSPI,则应使用Windows身份验证与SQL(Custom_DataSource)连接。

我试图创建派生类

CustomReportCredential:Microsoft.Reporting.WebForms.IReportServerCredentials 

但即使没有工作了。修改web.config以保持模拟(true/false),和许多类似的。他们都没有解决。

目前的情况下: 如果我改变报表中使用Windows集成安全,都使我的Windows身份验证连接字符串的正常运行,但无法对一个人的有指定的用户名和密码。

反之亦然,如果我更改要使用的报告提示输入凭据(勾选“用作Windows凭据”未勾选)。

预计:

  • 我怎么能允许连接到数据源的两种方法(Windows/SQL)?

这可能是一个微不足道的场景,但我无法找到适当的解决方案。

任何帮助或指针将不胜感激。谢谢。

回答

-1

我发现这寻找关于类似场景的不同答案。不过,我将rptViewer.ServerReport.ReportServerCredentials设置为可访问报告的Windows帐户。没有这一点,我提供的连接字符串没有什么区别,应用程序甚至无法访问报告。我看到这是旧的,但那也许是你的问题?我只是想知道,如果连接字符串在使用参数传递给报表时还有更多的危险,并且还有一个更好的选择,而不是必须在web.config中存储AD帐户和密码ReportViewer有权访问报告。

相关问题