Example #1
0
        private async Task ImportDataSource(SsrsDataSource item)
        {
            var definition = new DataSourceDefinition();

            new SsrsDataSourceDefinitionMapper().MapFromSsrsObject(definition, item);

            var parentPath = await service.GetOrCreateContainer(item.Path, log);

            log.DebugFormat("Importing data source: '{0}'", item.Path);
            try
            {
                await service.Proxy.CreateDataSourceAsync(new CreateDataSourceRequest {
                    TrustedUserHeader = trustedUserHeader,
                    DataSource        = item.Name,
                    Parent            = parentPath,
                    Overwrite         = Overwrite,
                    Definition        = definition
                });
            }
            catch (FaultException)
            {
                if (Overwrite)
                {
                    throw;              // Failure wasn't caused by existence of item.
                }
                if (!await service.ItemExists(item.Path))
                {
                    throw;
                }
            }
        }
Example #2
0
        private void DescribeDataSource(TextWriter output, SsrsDataSource dataSource)
        {
            output.WriteLine($"Connection string:   {HideConnectionStringPassword(dataSource.ConnectionString)}");

            switch (dataSource.Authentication)
            {
            case SsrsDataSource.AuthenticationType.StoredCredentials stored:
                output.WriteLine("Authentication:      Stored credentials");
                if (stored.WindowsCredentials)
                {
                    output.WriteLine($"    Domain:          {stored.Domain ?? ""}");
                }
                output.WriteLine($"    User Name:       {stored.UserName}");
                output.WriteLine("    Password:        <hidden>");
                break;

            case SsrsDataSource.AuthenticationType.WindowsIntegrated _:
                output.WriteLine("Authentication:      Windows Integrated");
                break;

            case SsrsDataSource.AuthenticationType.Prompt _:
                output.WriteLine("Authentication:      Prompt for credentials");
                break;

            case SsrsDataSource.AuthenticationType.None _:
                output.WriteLine("Authentication:      None");
                break;
            }
        }
        public void MapFromSsrsObject(DataSourceDefinition definition, SsrsDataSource item)
        {
            definition.Extension     = "SQL";
            definition.ConnectString = item.ConnectionString;
            switch (item.Authentication)
            {
            case SsrsDataSource.AuthenticationType.StoredCredentials stored:
                definition.CredentialRetrieval = CredentialRetrievalEnum.Store;
                definition.UserName            = String.IsNullOrWhiteSpace(stored.Domain) ? stored.UserName : $"{stored.Domain}\\{stored.UserName}";
                definition.Password            = stored.Password;
                definition.WindowsCredentials  = stored.WindowsCredentials;
                break;

            case SsrsDataSource.AuthenticationType.WindowsIntegrated _:
                definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
                break;

            case SsrsDataSource.AuthenticationType.Prompt _:
                definition.CredentialRetrieval = CredentialRetrievalEnum.Prompt;
                break;

            case SsrsDataSource.AuthenticationType.None _:
                definition.CredentialRetrieval = CredentialRetrievalEnum.None;
                break;

            default:
                throw new ArgumentOutOfRangeException($"[BUG] Unknown authentication type: {item.Authentication.GetType()}");
            }
        }
Example #4
0
 public CreateDataSourceJob(
     IReportingServiceClient service,
     SsrsDataSource dataSource
     )
 {
     this.service    = service ?? throw new ArgumentNullException(nameof(service));
     this.dataSource = dataSource ?? throw new ArgumentNullException(nameof(dataSource));
 }
        private Task ExportDataSource(string directoryPath, SsrsDataSource dataSource)
        {
            var filePath = Path.Combine(directoryPath, $"{dataSource.Name}.rds");
            var xml      = new XDocument(
                new XElement("RptDataSource",
                             new XAttribute("Name", dataSource.Name),
                             new XElement("ConnectionProperties",
                                          new XElement("Extension", "SQL"),
                                          new XElement("ConnectString", dataSource.ConnectionString),
                                          new XElement("IntegratedSecurity", dataSource.Authentication as SsrsDataSource.AuthenticationType.WindowsIntegrated)),
                             new XElement("DataSourceID")));

            xml.Save(filePath);
            return(Task.CompletedTask);
        }