A Secure Way of Building Connection Strings - Entering valid connection information
(Page 5 of 5 )
The TechnicalWriter is typing in the correct values for the various items on the ConnectionString builder form as shown. When he clicks the button he will see the following display. You can see that the clear text password is easy to read.

User types in wrong UserID
In this case, while he types in all other information correctly, he types the UserID incompletely as shown. Of course there is no user called Technical in the server.

User types in the server name incorrectly
In this case he incorrectly types in the server name which has the syntax Domain/Server. All other information is correct. He sees the following display. Notice the spelling error in the SQL Server. The error message is the most frequent one that you see, which does not really show the exact error that might have occurred, although in this case it points to failure due to locating the server. The complete message is shown here:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Summary
This SqlConnectionStringBuilder class will generate a connection string whose syntax and key/value pairs are checked against the database and invalid Key/Values or nested Key/Values will throw an exception. The SqlConnectionStringBuilder class simplifies the management and security of connection strings for connecting to MS SQL Servers. SqlConnectionStringBuilder can also be used for picking up the information from the configuration file. Similar classes exist for other default data providers such as Oracle. The builder can also be used to parse and modify the connection string to suit the needs of the application.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |