Click here to Skip to main content
15,896,348 members
Articles / Programming Languages / Visual Basic

Securing ADO.NET Connection Strings

Rate me:
Please Sign up or sign in to vote.
2.67/5 (11 votes)
25 Aug 20063 min read 51.4K   1.1K   29  
Some possible ways to encrypt and store connection strings in an ADO.NET application.
Imports System.ComponentModel
'''
<DefaultPropertyAttribute("DataSource")> _
Public Class DateBaseParameters
    Private _Password As String
    Private _WorkstationID As String
    Private _DataSource As String
    Private _InitialCatalog As String
    Private _UserID As String
    Private _PersistSecurityInfo As Boolean
    Private _IntegratedSecurity As Boolean

    '''
    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("Password for the SQL Server acount.")> _
       Public Property Password() As String
        Get
            Return _Password
        End Get
        Set(ByVal Value As String)
            _Password = Value
        End Set
    End Property
    '''

    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("The name of the workstation connecting to SQL Server.")> _
       Public Property WorkstationID() As String
        Get
            Return _WorkstationID
        End Get
        Set(ByVal Value As String)
            _WorkstationID = Value
        End Set
    End Property
    '''
    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("The name or network address of the instance of SQL Server to connect to.")> _
       Public Property DataSource() As String
        Get
            Return _DataSource
        End Get
        Set(ByVal Value As String)
            _DataSource = Value
        End Set
    End Property
    '''
    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("The name of the database associated with the connection.")> _
       Public Property InitialCatalog() As String
        Get
            Return _InitialCatalog
        End Get
        Set(ByVal Value As String)
            _InitialCatalog = Value
        End Set
    End Property
    '''
    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute(""), _
       DesignOnly(False), _
       DescriptionAttribute("User ID to be used when connecting to SQL Server.")> _
       Public Property UserID() As String
        Get
            Return _UserID
        End Get
        Set(ByVal Value As String)
            _UserID = Value
        End Set
    End Property
    '''
    <CategoryAttribute("Connection strings parametrs"), _
       Browsable(True), _
       [ReadOnly](False), _
       BindableAttribute(False), _
       DefaultValueAttribute("False"), _
       DesignOnly(False), _
       DescriptionAttribute("Indicates if security-sensitive information,such as password," & _
"is not returned as part of the connection if the connection is open or has ever been in an open state.")> _
       Public Property PersistSecurityInfo() As Boolean
        Get
            Return _PersistSecurityInfo
        End Get
        Set(ByVal Value As Boolean)
            _PersistSecurityInfo = Value
        End Set
    End Property

    <CategoryAttribute("Connection strings parametrs"), _
    Browsable(True), _
    [ReadOnly](False), _
    BindableAttribute(False), _
    DefaultValueAttribute("False"), _
    DesignOnly(False), _
    DescriptionAttribute("Indicates whether User ID and Password are specified in the connection (when false) " & _
    "or whether the current Windows account credentials are used for authentication (when true).")> _
   Public Property IntegratedSecurity() As Boolean
        Get
            Return _IntegratedSecurity
        End Get
        Set(ByVal Value As Boolean)
            _IntegratedSecurity = Value
        End Set
    End Property

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Georgia Georgia
Lecturer in Gori University (Georgia)

Comments and Discussions