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
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.
Re: trusted sql server connection
Here's an example of my conn string. I take it you'reusing ADO.NET?
VB Code:
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