In Microsoft.Practices.EnterpriseLibrary.Data.Sql.SqlDatabaseAssembler decrypt "connectionStringSettings.ConnectionString" as you wish before calling SqlDatabase
public Database Assemble(string name, ConnectionStringSettings connectionStringSettings, IConfigurationSource configurationSource)
{
string conn = YourDecryptionLogic(connectionStringSettings.ConnectionString)
return new SqlDatabase(conn);
}
This cool man...one more thing if you can post this link to the forums where users wants to do this...
ReplyDeleteCheers
Sure but meanwhile i figured out another easy way for this...call following at start of your code. You may change OpenExeConfiguration with OpenMappedExeConfiguration if using custom config files...
ReplyDeletestring sectionName = "connectionstrings";
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null)
{
if (!section.IsReadOnly())
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
section.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Modified);
}
}
ConfigurationManager.RefreshSection(sectionName);