How do I safely store database login and password in a C# application?

c#, passwords, sql-server

Solution

Use integrated Windows authentication whenever possible. It takes the onus off of your application and lets Windows handle it. Using Windows authentication instead of SQL authentication is considered a best practice.

Read this accepted answer: the best way to connect sql server (Windows authentication vs SQL Server authentication) for asp.net app

See also: http://www.mssqltips.com/sqlservertip/1831/using-windows-groups-for-sql-server-logins-as-a-best-practice/

And: http://www.greensql.com/content/sql-server-security-best-practices

Incidentally, if this is a "job" as implied by the question, it may be a great candidate for a simple Windows service or scheduled task, both of which can run in a specific security context (i.e. as a specific Windows user).

Problem

I have a C# application that needs to connect to an SQL database to send some data from time to time. How can I safely store the username and password used for this job?

Original source

Related problems