I have an application that connects to SQL Server using windows credentials, which works very well for the domain paradigm. The client is now transitioning away from having a domain server, and is going to a distributed model using Sharepoint (the company is perhaps only going to exist for another couple of years). The application I developed is critical to their ongoing operations, and their IT company and I are thinking that we will move to using SQL Server authentication so that they can use simple file server and VPN connections.
So I am adding the capability for the user to enter the password and will then create a credential, and from that the connection string. I'd like the user to only have to do that once, so I want the connection string to persist once it is successful so that subsequent calls to the DBML datacontext class can pass it in rather than getting it from Properties.Settings.Default as it currently does.
My thought is that I will save the connection string within the App object, and that all my view models can get to that to retrieve it, open the connection, and then create the DBML data context with the connection itself:
SqlCredential credential = ((App)Application.Current).Credential; SqlConnection conn = new SqlConnection(ConnectionString, credential); MyDataContext dc = new MyDataContext(conn);
I am wondering if this is the right way to achieve some level of security while moving away from the windows authentication, and also allowing the connection password to change without having to rebuild.