Hi,
I've been convinced to use windows setup files(msi) for the installation of my new windows forms application after I asked a question here and got some excellent answers (thank you all): http://serverfault.com/questions/97039/net-application-deployment
Now i have a different question:
My application will need to access a SQL Server to provide users with data, which means that the connection string must be stored in the client's app.config file.
How should I handle this?
During installation, the user enters the connection string to that database? How they get the connection string? In an email from the admin? What if the admin wants to use SQL authentication and need to put the user info at the connection string?
So you know, the app will be sold via the internet, so I don't have any access to the admins or the network.
Any suggestions?
Thanks in advanced.
-
Consider that the connection information may change at any point in the application's lifespan. Because of this, installation time is not the best location for this to occur.
Most commonly, you'll want to prompt the user for this information at startup if it is not already present, or if it is present but connection/login fails (with an appropriate error message). Upon successful login, store the information in the registry or whichever app config data solution you're using. You may also want to look at encrypting this data for security purposes, if you think that clients will be using per-user authentication.
Marc : Hm. Perhaps an auto-config option, where the client enters the name of a server (provided by the admin), which in turn does nothing but provide the necessary credentials? That way, the only thing you're storing locally is the hostname of that server. This also gives flexibility in terms of changing DB server connection info (including expired passwords, etc).Marc : It sounds like you already have a server component for this, or is it just the database that resides on the server? If you do already have a server component, then could you modify that to include this service? It need not be as heavy as a web service - a simple socket listener/response could do it.Marc : One rather messy possibility would be store the info in a registry location; and require the client admins to push out registry updates to the individual users/groups via login scripts. Far from ideal... but I don't know that there are many other paths open to you. Either an authoritative source (server call), require user input at install or runtime, or this. There are really not many options to do something automatically when the values must be supplied by a human; and those values are not fixed for the life of the application.From Marc -
Store the connection string in the app.config encrypted, you can use your own encryption or the configuration classes in .Net have encryption methods built in. Make sure you use something besides the default machine encryption so the admin could create a config file and use that on his/her local network install.
Like Marc says check on start up if there is a valid connection if not prompt the user for connection method. The local admin can run the app create the config settings and deploy them from there.
Ross
From boezo
0 comments:
Post a Comment