Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to store a connection string used by many applications in the same machine?

At my shop we are used to store connections strings in the .config file. But when we had to update it in several applications in the same machine someone gave the idea of storing it on the windows registry.

Is this a good idea? What are the implications (security)?

like image 380
Jader Dias Avatar asked Jan 27 '10 17:01

Jader Dias


People also ask

Where should you store the connection string information?

Connection strings in configuration files are typically stored inside the <connectionStrings> element in the app. config for a Windows application, or the web. config file for an ASP.NET application.

Where is the storage account connection string?

You can find your storage account's connection strings in the Azure portal. Navigate to SETTINGS > Access keys in your storage account's menu blade to see connection strings for both primary and secondary access keys.

Is it safe to store connection string in web config?

The connection strings are mostly stored in web. config. It means that connection specific information such as database name, username, and password are stored as a clear text in a file. This is definitely a security concern for your Production servers.

When the connection string is saved with the application it is stored in the?

The Connection String will be stored (saved) in the App. Config file inside its ConnectionStrings section and later it will be read in code using the ConfigurationManager class in C# and VB.Net. In Windows applications, Class Library or Console applications one has to reference the System.


3 Answers

You can store it in machine.config. All .config files will inherit any connection strings defined therein unless explicitly cleared.

like image 111
Mark Seemann Avatar answered Sep 30 '22 18:09

Mark Seemann


We are storing common data in the registry in encrypted form. modifying Machine.config is a very scary operation. ;) One disadvantage is a registry security. And 64bit windows can make working with registry a very weird. especially on WoW mode.

Also registry for administrators is a very old and well known friend (backup, restore, import, export etc is not a new for them). as for machine.config I wish they never wants touch it.

like image 42
Sergey Mirvoda Avatar answered Sep 30 '22 18:09

Sergey Mirvoda


Maybe you could just have a common component (WCF or otherwise) that you reference for connection strings. That way you'd only have to store the string in one place.

I wouldn't use the Windows Registry for application specific settings like that, though I know plenty of other apps do...

like image 43
Tad Donaghe Avatar answered Sep 30 '22 18:09

Tad Donaghe