【问题标题】:SSRS - Programmatically update password in Data source credentialsSSRS - 以编程方式更新数据源凭据中的密码
【发布时间】:2021-09-08 23:20:49
【问题描述】:

我们使用 SQL Server 2017。我们的 SSRS Reports 数据源凭据使用 登录数据源“使用以下凭据”并选择“Windows 用户名和密码”。

如何在此处以编程方式更改密码?

下面的C#代码运行成功,但是当我回到SSRS报告“/MyFolder/MyReport”时,密码没有改变(我知道这是因为我最初在这里输入了错误的密码,并且在代码运行后,我回到这里并单击“测试连接”,它给我一个错误“登录失败。请确保用户名和密码正确。”

ReportingService2010.ReportingService2010 rsClient = new ReportingService2010.ReportingService2010();
rsClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

CatalogItem[] items = null;

DataSource[] dataSources = rsClient.GetItemDataSources("/MyFolder/MyReport");
DataSource ds = dataSources[0];
DataSourceDefinition dsd = (DataSourceDefinition)ds.Item;
dsd.Password = "MyPwd";

【问题讨论】:

  • 为什么要同时发两次same question
  • @Micky 认为日期时间戳是相同的,这表明是网站问题而不是用户问题。
  • 是的,看起来是个小故障

标签: c# sql-server reporting-services


【解决方案1】:

我对您引用的特定 ReportingService2010 程序集没有太多经验,但查看 Microsoft 文档,您似乎需要使用您创建的 DataSourceDefinition 实例使用方法 @987654324 设置 DataSource 内容@。

ReportingService2010.ReportingService2010 rsClient = new ReportingService2010.ReportingService2010();
rsClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
DataSource[] dataSources = rsClient.GetItemDataSources("/MyFolder/MyReport");
DataSource ds = dataSources[0];
DataSourceDefinition dsd = (DataSourceDefinition)ds.Item;
dsd.Password = "MyPwd";
/*set all other DataSourceDefinition values*/
rsClient.SetDataSourceContents("url_to_data_source_here",dsd); 

您当前的示例基本上是设置 DataSourceDefinition 值,然后对它们不做任何事情。

完成 Microsoft doc 到 SetDataSourceContents 方法 here

【讨论】:

  • 非常感谢您的帮助!这条语句成功了 rsClient.SetItemDataSources("/MyFolder/MyReport", dataSources);
  • 而且,是的,我不认为我两次发布了这个问题,但不知何故它出现了两次。感谢您的理解。
猜你喜欢
  • 1970-01-01
  • 2021-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多