接続文字列を暗号化して web.config に保存する必要がある Web アプリケーションがあります。
接続文字列を SqlMap.config に保存する代わりに、これを取得して IBATIS.NET でこの接続文字列を使用する最良の方法は何ですか?
接続文字列を暗号化して web.config に保存する必要がある Web アプリケーションがあります。
接続文字列を SqlMap.config に保存する代わりに、これを取得して IBATIS.NET でこの接続文字列を使用する最良の方法は何ですか?
このディスカッションスレッドの最後の3つのメッセージでは、必要なものについて説明しています。
基本的に、Configure()を呼び出す前に、構成ファイルからiBATISがロードする接続文字列を上書きします。
たとえば、SqlMap.configでは次のようになります。
<database>
<provider name="sqlServer2005" />
<dataSource name="TheDB" connectionString="${connectionString}"/>
</database>
そして、ビルダーを構成するコードでは、次のようになります。
DomSqlMapBuilder builder;
string connection;
NameValueCollection properties;
connection = AccessTheEncryptedStringHere();
// Put the string in collection to pass to the iBATIS configurator
properties = new NameValueCollection();
properties.Add("connectionString", connection);
// Build the iBATIS configurator
builder = new DomSqlMapBuilder();
builder.Properties = properties;
builder.Configure("SqlMap.config");
これに気をつけていますか?暗号化された接続文字列を web.config から取得する --
フォールを試すことができます。code -- 接続文字列の名前は omni_dbConnectionString です
string connectionString = ConfigurationManager.ConnectionStrings["myProtectedConfigProvider"].ProviderName;
また
string connectionString = ConfigurationManager.ConnectionStrings["omni_dbConnectionString"].ConnectionString;