1

Closed

Setting CredentialRetrievalEnum on DataSourceDefinition

description

Ok, I made a few source changes, recompiled, and I've got this working. The changes I made are as follows:

Added a property to the ReportServerDataSource.cs class:



/// <summary>
/// Gets or sets the prompt displayed to the user when asking for security credentials.
/// </summary>
/// <value>A string containing the text to use to prompt the user for credentials.</value>
public string CredentialsPrompt { get; set; }






Added the following code to the Execute method in CreateReportingDataSource.cs:



if (!String.IsNullOrEmpty(this.DataSources[index].GetMetadata("Prompt")))
{
reportServerDataSources[index].CredentialsPrompt = this.DataSources[index].GetMetadata("Prompt");
}




Modified the GetDataSourceDefinition method in NativeDeploymentManager.cs as follows:



/// <summary>
/// Gets the data source definition.
/// </summary>
/// <param name="dataSource">
/// The data source.
/// </param>
/// <param name="sqlConStringBuilder">
/// The SQL con string builder.
/// </param>
/// <returns>
/// DataSourceDefinition with default setting created.
/// </returns>
private DataSourceDefinition GetDataSourceDefinition(
ReportServerDataSource dataSource, SqlConnectionStringBuilder sqlConStringBuilder)
{
// create a data source definition and apply default settings
DataSourceDefinition definition = new DataSourceDefinition();
this.SetDefaultDefinition(definition);

// setting the conection string bas up the type
switch (dataSource.Provider)
{
case DataProviderEnum.SQL:
definition.Extension = "SQL";
break;
case DataProviderEnum.OLEDBMD:
definition.Extension = "OLEDB-MD";
break;
}

// get the Data Source and Catalogs
definition.ConnectString = string.Format(
"Data Source={0};Initial Catalog={1}",
sqlConStringBuilder.DataSource,
sqlConStringBuilder.InitialCatalog);

// check to if windows security is used or in the provicer is AS
if (sqlConStringBuilder.IntegratedSecurity || dataSource.Provider == DataProviderEnum.OLEDBMD)
{
definition.WindowsCredentials = true;

// checking to see if the impersonation needs to be set.
if (dataSource.WindowCredentials != null)
{
// set impersonation details of the windows user
definition.UserName = dataSource.WindowCredentials.UserName;
definition.Password = dataSource.WindowCredentials.PassWord;
definition.CredentialRetrieval = CredentialRetrievalEnum.Store;
}
else
{
// user standard windows / Kebross security
definition.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
}
}
else
{
if (!string.IsNullOrEmpty(sqlConStringBuilder.UserID))
{
// llse use SQL Server security
definition.UserName = sqlConStringBuilder.UserID;
definition.Password = sqlConStringBuilder.Password;
definition.CredentialRetrieval = CredentialRetrievalEnum.Store;
}
else
{
if (!string.IsNullOrEmpty(dataSource.CredentialsPrompt))
{
// Prompt the user for security credentials
definition.Prompt = dataSource.CredentialsPrompt;
definition.CredentialRetrieval = CredentialRetrievalEnum.Prompt;
}
else
{
// No security credentials required
definition.CredentialRetrieval = CredentialRetrievalEnum.None;
}
}
}

return definition;
}






So, I've got it working now. It would be great if something along these lines was added to the project if it's still being maintained. Anyway, hope that helps somebody.

No files are attached

Closed Feb 1 at 8:47 PM by StevenJWright

Added the code into the release


comments