Best place for connection string

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Best place for connection string

    Hi,

    At present I have an include file that defines my database connection
    string. This file is inluded on every page that uses database access.
    However I would like to ask if a better place for this string would be in an
    pplication variable.
    I know it is not a good idea to cache the actually database connection, but
    in this case I am only talking about the actual string.

    One other point is that where ever the connection string is it currently had
    the database username and password (sql authentication)
    hard coded into it, is this the standard ay to do things or is there a trick
    I can employ to hide the password, that is not too expensive.
    I thought about placing it in the registry, but then maybe a trip to the
    registry before every database connection is not a good idea.



    cheers

    martin.


    martin de vroom Guest

  2. Similar Questions and Discussions

    1. need help with connection string
      i keep reading that it is not secure to hard code the connection string to the server into my swf. so how can i get the string into my swf without...
    2. connection string
      Hi there, I have recently changed the connection string on a site that was working perfectly. I used an OLE DB connection with this code: var...
    3. DB Connection String
      Hi, I need to store the database connection string inside web.config file. What would be the best way to encrypt and decrypt it? Thanks, Ali
    4. Encrypted Connection String
      How would I go about taking my DB connection strings and putting them into my Web.Config file in encrypted form? Of course, I'd need to know how to...
    5. Oracle DSN Less Connection String
      Greetings.... Okay so far Dreamweaver MX connection to Oracle has left an awful bitter taste in my mouth.... I am trying a DSN Less Oracle...
  3. #2

    Default Re: Best place for connection string

    You could use a DSN, in which case the connection string parameters are
    stored in the database, not hard coded in clear in your global.asa file.

    On the other hand, it is preferable to use OLEDB Providers rather than ODBC
    Drivers.

    If you are using SQL Server, then you can switch to Windows Integrated
    Authentication (rather than Mixed Mode). This means that you (or your ASP
    page) logs in to SQL Server using its Windows account rather than
    username/password passed in via the connection string. This means you have
    no password anywhere in the clear.

    Cheers
    Ken

    "martin de vroom" <martindevroom@hotmail.com> wrote in message
    news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    : Hi,
    :
    : At present I have an include file that defines my database connection
    : string. This file is inluded on every page that uses database access.
    : However I would like to ask if a better place for this string would be in
    an
    : pplication variable.
    : I know it is not a good idea to cache the actually database connection,
    but
    : in this case I am only talking about the actual string.
    :
    : One other point is that where ever the connection string is it currently
    had
    : the database username and password (sql authentication)
    : hard coded into it, is this the standard ay to do things or is there a
    trick
    : I can employ to hide the password, that is not too expensive.
    : I thought about placing it in the registry, but then maybe a trip to the
    : registry before every database connection is not a good idea.
    :
    :
    :
    : cheers
    :
    : martin.
    :
    :


    Ken Schaefer Guest

  4. #3

    Default Re: Best place for connection string

    "martin de vroom" <martindevroom@hotmail.com> wrote in message
    news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    > Hi,
    >
    > At present I have an include file that defines my database
    connection
    > string. This file is inluded on every page that uses database access.
    > However I would like to ask if a better place for this string would be
    in an
    > pplication variable.
    > I know it is not a good idea to cache the actually database
    connection, but
    > in this case I am only talking about the actual string.
    >
    > One other point is that where ever the connection string is it
    currently had
    > the database username and password (sql authentication)
    > hard coded into it, is this the standard ay to do things or is there a
    trick
    > I can employ to hide the password, that is not too expensive.
    > I thought about placing it in the registry, but then maybe a trip to
    the
    > registry before every database connection is not a good idea.
    >
    >
    >
    > cheers
    >
    > martin.
    >
    >
    OS? Database? Version? MDAC?

    Consider using a Microsoft Datalink file.
    [url]http://msdn.microsoft.com/library/en-us/oledb/htm/olprcore_chapter20_6.asp[/url]

    The file can be stored outside the application root and your connection
    string is simply a reference to the file. Therefore, even if there is an
    unauthorized access to your application directory or an unhandled
    exception is exploited to reveal the connection string, sensitive
    information like database username/password is not exposed.

    HTH
    -Chris



    Chris Hohmann Guest

  5. #4

    Default Re: Best place for connection string

    Thanks for that,

    I'd prefer not to use a DSN.

    however, how does connecting to SQL Server using windows integrated security
    affect connection pooling.
    for example using a sql authentication string for every connection ensures
    that the connection strring is always the same.

    admittedly it will be the same every time however it will pass different
    credentials most times.
    I take it that I will have to pick the windows ID up using NTLM, this is a
    great solution for an intranet - which is the enviroment i am in -
    as i will just add the evryone group to sql server and grant the appropraite
    permissions.
    however I would be interested to know if this affects connction pooling.

    Is there anyway to test this.

    cheers

    martin



    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:#0JMsyySDHA.2460@TK2MSFTNGP10.phx.gbl...
    > You could use a DSN, in which case the connection string parameters are
    > stored in the database, not hard coded in clear in your global.asa file.
    >
    > On the other hand, it is preferable to use OLEDB Providers rather than
    ODBC
    > Drivers.
    >
    > If you are using SQL Server, then you can switch to Windows Integrated
    > Authentication (rather than Mixed Mode). This means that you (or your ASP
    > page) logs in to SQL Server using its Windows account rather than
    > username/password passed in via the connection string. This means you have
    > no password anywhere in the clear.
    >
    > Cheers
    > Ken
    >
    > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    > news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    > : Hi,
    > :
    > : At present I have an include file that defines my database connection
    > : string. This file is inluded on every page that uses database access.
    > : However I would like to ask if a better place for this string would be
    in
    > an
    > : pplication variable.
    > : I know it is not a good idea to cache the actually database connection,
    > but
    > : in this case I am only talking about the actual string.
    > :
    > : One other point is that where ever the connection string is it currently
    > had
    > : the database username and password (sql authentication)
    > : hard coded into it, is this the standard ay to do things or is there a
    > trick
    > : I can employ to hide the password, that is not too expensive.
    > : I thought about placing it in the registry, but then maybe a trip to the
    > : registry before every database connection is not a good idea.
    > :
    > :
    > :
    > : cheers
    > :
    > : martin.
    > :
    > :
    >
    >

    martin de vroom Guest

  6. #5

    Default Re: Best place for connection string

    On Wed, 16 Jul 2003 11:30:04 +1200, "martin de vroom"
    <martindevroom@hotmail.com> wrote:
    > At present I have an include file that defines my database connection
    >string. This file is inluded on every page that uses database access.
    >However I would like to ask if a better place for this string would be in an
    >pplication variable.
    >I know it is not a good idea to cache the actually database connection, but
    >in this case I am only talking about the actual string.
    That might work, though OI have to admit I only use includes to handle
    connections. Global.asa is another option.
    >One other point is that where ever the connection string is it currently had
    >the database username and password (sql authentication)
    >hard coded into it, is this the standard ay to do things or is there a trick
    >I can employ to hide the password, that is not too expensive.
    Hide from whom? Assuming this is ASP, code is executed on the server
    and not sent to the client.

    Jeff
    ===================================
    Jeff Cochran (IIS MVP)
    [email]jcochran.nospam@naplesgov.com[/email] - Munged of Course

    I don't get much time to respond to direct email,
    so posts here will have a better chance of getting
    an answer. Besides, everyone benefits here.

    Suggested resources:
    [url]http://www.iisfaq.com/[/url]
    [url]http://www.iisanswers.com/[/url]
    [url]http://www.iistoolshed.com/[/url]
    [url]http://securityadmin.info/[/url]
    [url]http://www.aspfaq.com/[/url]
    [url]http://support.microsoft.com/[/url]
    ====================================
    Jeff Cochran Guest

  7. #6

    Default Re: Best place for connection string

    If you are allowing IIS anonymous access then all access to SQL Server will
    be under the IUSR_<machinename> (or whatever you have configured in IIS), so
    connection pooling will still work.

    If you are forcing users to authenticate against the Windows accounts
    database (eg Basic or Integrated Authentication), then I'm not entirely sure
    what you can do - maybe SQL Server app roles could be of use here.

    Cheers
    Ken

    "martin de vroom" <martindevroom@hotmail.com> wrote in message
    news:eS4dE%23ySDHA.1912@tk2msftngp13.phx.gbl...
    : Thanks for that,
    :
    : I'd prefer not to use a DSN.
    :
    : however, how does connecting to SQL Server using windows integrated
    security
    : affect connection pooling.
    : for example using a sql authentication string for every connection ensures
    : that the connection strring is always the same.
    :
    : admittedly it will be the same every time however it will pass different
    : credentials most times.
    : I take it that I will have to pick the windows ID up using NTLM, this is a
    : great solution for an intranet - which is the enviroment i am in -
    : as i will just add the evryone group to sql server and grant the
    appropraite
    : permissions.
    : however I would be interested to know if this affects connction pooling.
    :
    : Is there anyway to test this.
    :
    : cheers
    :
    : martin
    :
    :
    :
    : "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    : news:#0JMsyySDHA.2460@TK2MSFTNGP10.phx.gbl...
    : > You could use a DSN, in which case the connection string parameters are
    : > stored in the database, not hard coded in clear in your global.asa file.
    : >
    : > On the other hand, it is preferable to use OLEDB Providers rather than
    : ODBC
    : > Drivers.
    : >
    : > If you are using SQL Server, then you can switch to Windows Integrated
    : > Authentication (rather than Mixed Mode). This means that you (or your
    ASP
    : > page) logs in to SQL Server using its Windows account rather than
    : > username/password passed in via the connection string. This means you
    have
    : > no password anywhere in the clear.
    : >
    : > Cheers
    : > Ken
    : >
    : > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    : > news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    : > : Hi,
    : > :
    : > : At present I have an include file that defines my database
    connection
    : > : string. This file is inluded on every page that uses database access.
    : > : However I would like to ask if a better place for this string would be
    : in
    : > an
    : > : pplication variable.
    : > : I know it is not a good idea to cache the actually database
    connection,
    : > but
    : > : in this case I am only talking about the actual string.
    : > :
    : > : One other point is that where ever the connection string is it
    currently
    : > had
    : > : the database username and password (sql authentication)
    : > : hard coded into it, is this the standard ay to do things or is there a
    : > trick
    : > : I can employ to hide the password, that is not too expensive.
    : > : I thought about placing it in the registry, but then maybe a trip to
    the
    : > : registry before every database connection is not a good idea.
    : > :
    : > :
    : > :
    : > : cheers
    : > :
    : > : martin.
    : > :
    : > :
    : >
    : >
    :
    :


    Ken Schaefer Guest

  8. #7

    Default Re: Best place for connection string

    Hi Ken,

    As I understand app roles, you still have to connect using either sql or
    windows authentication, and then execute the sp to make app roles kick in.
    maybe I'll just stick with sql server authtitcation first.

    any idea how i would test how logging on with windows authentication affects
    connection pooling.

    cheers

    martin.


    "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    news:uIbYLt7SDHA.2276@TK2MSFTNGP10.phx.gbl...
    > If you are allowing IIS anonymous access then all access to SQL Server
    will
    > be under the IUSR_<machinename> (or whatever you have configured in IIS),
    so
    > connection pooling will still work.
    >
    > If you are forcing users to authenticate against the Windows accounts
    > database (eg Basic or Integrated Authentication), then I'm not entirely
    sure
    > what you can do - maybe SQL Server app roles could be of use here.
    >
    > Cheers
    > Ken
    >
    > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    > news:eS4dE%23ySDHA.1912@tk2msftngp13.phx.gbl...
    > : Thanks for that,
    > :
    > : I'd prefer not to use a DSN.
    > :
    > : however, how does connecting to SQL Server using windows integrated
    > security
    > : affect connection pooling.
    > : for example using a sql authentication string for every connection
    ensures
    > : that the connection strring is always the same.
    > :
    > : admittedly it will be the same every time however it will pass different
    > : credentials most times.
    > : I take it that I will have to pick the windows ID up using NTLM, this is
    a
    > : great solution for an intranet - which is the enviroment i am in -
    > : as i will just add the evryone group to sql server and grant the
    > appropraite
    > : permissions.
    > : however I would be interested to know if this affects connction pooling.
    > :
    > : Is there anyway to test this.
    > :
    > : cheers
    > :
    > : martin
    > :
    > :
    > :
    > : "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    > : news:#0JMsyySDHA.2460@TK2MSFTNGP10.phx.gbl...
    > : > You could use a DSN, in which case the connection string parameters
    are
    > : > stored in the database, not hard coded in clear in your global.asa
    file.
    > : >
    > : > On the other hand, it is preferable to use OLEDB Providers rather than
    > : ODBC
    > : > Drivers.
    > : >
    > : > If you are using SQL Server, then you can switch to Windows Integrated
    > : > Authentication (rather than Mixed Mode). This means that you (or your
    > ASP
    > : > page) logs in to SQL Server using its Windows account rather than
    > : > username/password passed in via the connection string. This means you
    > have
    > : > no password anywhere in the clear.
    > : >
    > : > Cheers
    > : > Ken
    > : >
    > : > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    > : > news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    > : > : Hi,
    > : > :
    > : > : At present I have an include file that defines my database
    > connection
    > : > : string. This file is inluded on every page that uses database
    access.
    > : > : However I would like to ask if a better place for this string would
    be
    > : in
    > : > an
    > : > : pplication variable.
    > : > : I know it is not a good idea to cache the actually database
    > connection,
    > : > but
    > : > : in this case I am only talking about the actual string.
    > : > :
    > : > : One other point is that where ever the connection string is it
    > currently
    > : > had
    > : > : the database username and password (sql authentication)
    > : > : hard coded into it, is this the standard ay to do things or is there
    a
    > : > trick
    > : > : I can employ to hide the password, that is not too expensive.
    > : > : I thought about placing it in the registry, but then maybe a trip to
    > the
    > : > : registry before every database connection is not a good idea.
    > : > :
    > : > :
    > : > :
    > : > : cheers
    > : > :
    > : > : martin.
    > : > :
    > : > :
    > : >
    > : >
    > :
    > :
    >
    >

    martin de vroom Guest

  9. #8

    Default Re: Best place for connection string

    You can use Profiler if you want lots of info.

    sp_who / sp_who2 can be used to get a "snap shot" view

    Cheers
    Ken


    "martin de vroom" <martindevroom@hotmail.com> wrote in message
    news:eDXVEO%23SDHA.3700@tk2msftngp13.phx.gbl...
    : Hi Ken,
    :
    : As I understand app roles, you still have to connect using either sql
    or
    : windows authentication, and then execute the sp to make app roles kick in.
    : maybe I'll just stick with sql server authtitcation first.
    :
    : any idea how i would test how logging on with windows authentication
    affects
    : connection pooling.
    :
    : cheers
    :
    : martin.
    :
    :
    : "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    : news:uIbYLt7SDHA.2276@TK2MSFTNGP10.phx.gbl...
    : > If you are allowing IIS anonymous access then all access to SQL Server
    : will
    : > be under the IUSR_<machinename> (or whatever you have configured in
    IIS),
    : so
    : > connection pooling will still work.
    : >
    : > If you are forcing users to authenticate against the Windows accounts
    : > database (eg Basic or Integrated Authentication), then I'm not entirely
    : sure
    : > what you can do - maybe SQL Server app roles could be of use here.
    : >
    : > Cheers
    : > Ken
    : >
    : > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    : > news:eS4dE%23ySDHA.1912@tk2msftngp13.phx.gbl...
    : > : Thanks for that,
    : > :
    : > : I'd prefer not to use a DSN.
    : > :
    : > : however, how does connecting to SQL Server using windows integrated
    : > security
    : > : affect connection pooling.
    : > : for example using a sql authentication string for every connection
    : ensures
    : > : that the connection strring is always the same.
    : > :
    : > : admittedly it will be the same every time however it will pass
    different
    : > : credentials most times.
    : > : I take it that I will have to pick the windows ID up using NTLM, this
    is
    : a
    : > : great solution for an intranet - which is the enviroment i am in -
    : > : as i will just add the evryone group to sql server and grant the
    : > appropraite
    : > : permissions.
    : > : however I would be interested to know if this affects connction
    pooling.
    : > :
    : > : Is there anyway to test this.
    : > :
    : > : cheers
    : > :
    : > : martin
    : > :
    : > :
    : > :
    : > : "Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
    : > : news:#0JMsyySDHA.2460@TK2MSFTNGP10.phx.gbl...
    : > : > You could use a DSN, in which case the connection string parameters
    : are
    : > : > stored in the database, not hard coded in clear in your global.asa
    : file.
    : > : >
    : > : > On the other hand, it is preferable to use OLEDB Providers rather
    than
    : > : ODBC
    : > : > Drivers.
    : > : >
    : > : > If you are using SQL Server, then you can switch to Windows
    Integrated
    : > : > Authentication (rather than Mixed Mode). This means that you (or
    your
    : > ASP
    : > : > page) logs in to SQL Server using its Windows account rather than
    : > : > username/password passed in via the connection string. This means
    you
    : > have
    : > : > no password anywhere in the clear.
    : > : >
    : > : > Cheers
    : > : > Ken
    : > : >
    : > : > "martin de vroom" <martindevroom@hotmail.com> wrote in message
    : > : > news:eGDWvkySDHA.2084@TK2MSFTNGP11.phx.gbl...
    : > : > : Hi,
    : > : > :
    : > : > : At present I have an include file that defines my database
    : > connection
    : > : > : string. This file is inluded on every page that uses database
    : access.
    : > : > : However I would like to ask if a better place for this string
    would
    : be
    : > : in
    : > : > an
    : > : > : pplication variable.
    : > : > : I know it is not a good idea to cache the actually database
    : > connection,
    : > : > but
    : > : > : in this case I am only talking about the actual string.
    : > : > :
    : > : > : One other point is that where ever the connection string is it
    : > currently
    : > : > had
    : > : > : the database username and password (sql authentication)
    : > : > : hard coded into it, is this the standard ay to do things or is
    there
    : a
    : > : > trick
    : > : > : I can employ to hide the password, that is not too expensive.
    : > : > : I thought about placing it in the registry, but then maybe a trip
    to
    : > the
    : > : > : registry before every database connection is not a good idea.
    : > : > :
    : > : > :
    : > : > :
    : > : > : cheers
    : > : > :
    : > : > : martin.
    : > : > :
    : > : > :
    : > : >
    : > : >
    : > :
    : > :
    : >
    : >
    :
    :


    Ken Schaefer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139