Results 1 to 3 of 3

Thread: trusted sql server connection

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Location
    Manchester England
    Posts
    11

    trusted sql server connection

    Hi all

    I am new to ASP .net and I am struggling gettin off the ground

    The SQL connection strings that have been working for me for windows forms dont work for web forms

    the error i get is

    Not associated with a trusted SQL server connection

    can you help?

    thanks
    Thanks
    Neal

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Re: trusted sql server connection

    By default, ASP.Net runs under a local system account (ASPNET if you go into the "Local Users & Groups" section in the Computer Management console). Any requests to ASP.Net pages are run under that user's context.
    Thus, without identity impersonation on, any connections to SQL Server that use integrated authentication use the ASPNET credentials. If ASPNET hasn't been added as a trusted user to SQL, you get that exception.

    So, you have three options:
    1) Add the ASPNET account as a trusted user in SQL Server, or
    2) Impersonate incoming user credentials by adding the following into your web.config. This impersonates any incoming user and runs processes in their context so you need to ensure that NTFS permissions are correct (read access and so forth - KB article available) and that they have access to SQL Server.
    Code:
    <system.web>
        <identity impersonate="true" />
    </system.web>
    3) Use a low privilege username & password in your connection string instead of integrated authentication.

    The difference here is that Windows applications run under the launching user's credentials - i.e. you open the app, all resource requests (excluding explicit impersonation) will use your credentials.

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: trusted sql server connection

    Here's an example of my conn string. I take it you'reusing ADO.NET?
    VB Code:
    1. Private Const CONN_STRING As String = "Server=(local);Database=ScratchDB;User ID=Woof;Password=penguin"
    Notice how it's almost 100% identical to the one you would use for normal ADO 2.1 to 2.8 in VB6. It's just missing a bit from the front.

    Woka

Posting Permissions

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



Click Here to Expand Forum to Full Width