Click here to Skip to main content
12,449,762 members (77,609 online)
Click here to Skip to main content

Stats

41.4K views
948 downloads
27 bookmarked
Posted

Securing ADO.NET Connection Strings

, 25 Aug 2006
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

Share

About the Author

Levan Midodashvili
Web Developer
Georgia Georgia
Lecturer in Gori University (Georgia)

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160826.1 | Last Updated 25 Aug 2006
Article Copyright 2006 by Levan Midodashvili
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid