Tuesday, January 12, 2010

Enterprise Library 2.0 Encrypted ConnectionString

Enterprise Library 2.0 connection string is not encrypted by default. So recompile "Microsoft.Practices.EnterpriseLibrary.Data" DLL with following change...

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);
}