MS SQL Server
  Home arrow MS SQL Server arrow A Secure Way of Building Connection String...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

A Secure Way of Building Connection Strings
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-11-14

    Table of Contents:
  • A Secure Way of Building Connection Strings
  • Reviewing member properties of the class
  • Reviewing properties using an example
  • Building a ConnectionString using the class
  • Entering valid connection information

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    A Secure Way of Building Connection Strings


    (Page 1 of 5 )

    Data sources hold some of the most important enterprise information. Securing this information is a top priority for any enterprise. Data sources are accessed through the connection string, a collection of name/value pairs connected with UserID, Password, Data Source Name, etc. that specify the run time parameters for connecting to databases. This article covers the use of SqlConnectionStringBuilder for MS SQL Server in securing information.

    Introduction

    The connection string is built using the name/value pairs stored in a secure location by concatenating the individual name/value pairs, the attributes, together. Sometimes parts of the connection string may come from the information entered by the user in some kind of a dialog box. In the earlier ADO.NET 1.1 version you could just concatenate the individual name/value pairs, which sometimes can result in a run time error because the connection string is not parsed at compilation.

    The other serious objection was the process of building the connection string. Pure concatenation easily gave access to spurious insertions -- the SQL injection. This is where the string builder class comes in handy. Simply stated, this class takes user input and comes up with a tamper-proof connection string. The connection string builder greatly reduces injection, thereby providing increased security. However for each of the data providers you will need a different builder because the connection information is different. The present tutorial looks at the SqlConnectionStringBuilder for MS SQL Server.

    Connection Strings

    Connection string formulation depends on the database product. The MS SQL Server 2005 connection string may use a different set of name/value pairs than, say, Oracle Server 10g. While constructing and managing the string is one of the concerns, securing and protecting it is another. Connection string key/value pairs are the same as those used in the earlier version with a couple of additional key/value pairs added in ADO.NET 2.0. They are not case sensitive.

    The reader is advised to look up some 20 or so Key Value pairs used in SQL 2005 server at MSDN. You will come across these later in this tutorial while reviewing the Object Browser. Typical information contained in the connection string includes the Server (or the Data source), UserID, Password, and the Database. It may also include other related information such as the connection timeout, whether asynchronous processing is allowed or not, and so forth.

    Overview of the tutorial

    The tutorial consists of two parts. In part 1, the SqlConnectionStringBuilder class will be introduced and the class members will be reviewed with an example. The typical connection used to access the SQL 2005 Server will be used. In part 2, another example will be used to create a connection string by supplying user inserted information in a form. The connection to SQL Server will be opened and closed to verify the correctness of the connection string. To test this, a user will be created in the SQL server with dbo permissions to a database on the server.

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


       · Security is one of the most important concerns and the hassle free SQL Connection...
     

    MS SQL SERVER ARTICLES

    - Windows Server 2008 as a Workstation OS
    - An Overview of Windows Server 2008 R2
    - LINQ to MySQL, Oracle and PostgreSQL Provide...
    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 12 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek