views:

134

answers:

3

I cannot seem to use a Windows account to access my database from my ASP page. Here is my connection string: PROVIDER=SQLOLEDB;DATA SOURCE=NHA-SQL-I0;UID=DOMAIN\NHA-svcRequestForm;PWD=password;DATABASE=RequestForms

I get the classic: Microsoft OLE DB Provider for SQL Server (0x80040E4D) Login failed for user 'NIRHB\NHA-svcRequestForm'.

This occurs for any domain account I use. Using SQL accounts works fine. Any idea what setting/configuration I am missing?

Thanks

+1  A: 

That type of connection string is used for SQL accounts; you're actually trying to connect as a SQL user named "DOMAIN\NHA-svcRequestForm".

Try somethign like this:

PROVIDER=SQLOLEDB;DATA SOURCE=NHA-SQL-I0;DATABASE=RequestForms;Trusted_Connection=YES

And whatever application is trying to connect to the database must be running as the domain user. This means the identity of the application pool must be set to your domain user (if this is a web app in IIS), or the service identity must be the domain user (if a windows service).

jenningj
Ok, so I have the app pool set to use the "DOMAIN\NHA-svcRequestForm" for the identity, but now I keep getting a "Service Unavailable" error when I try to load a page... Verified the username and password are correct. Added the connection string as you detailed above, but no go! Any idea what is wrong? I am used to more detailed messages than just "Service Unavailable"...
Kolten
Try adding that user to the IIS_WPG group on the server. Accounts acting as a worker process identity need certain permissions to function correctly.
jenningj
+1  A: 

Specifying user name and password in connection string works only for SQL authentication.

For integrated authentication (ie. use a 'domain account') you must specify Integrated Security=SSPI instead. You cannot specify an user name explicitly, SQL will authenticate the account running the process macking the connection (ie. ASP account).

If you want to authenticate domain users connected to your site you must turn on impersonation in your app pool and enable constrained delegation. See How To: Use Protocol Transition and Constrained Delegation in ASP.NET 2.0.

Remus Rusanu
I think he's using classic ASP, though... even so your answer still applies!
Yadyn
This is classic ASP.
Kolten
Constrained delegation and impersonation work the same in classic ASP. There are many guides on how to configure this, eg. http://technet.microsoft.com/en-us/library/dd296638(WS.10).aspx
Remus Rusanu
A: 

check out http://www.connectionstrings.com/sql-server-2005 they have all the connection strings and how to use trusted connection

Carter Cole