Friday, February 17, 2012

Connecting a web app to sql server

I have a web application running on Server A and need to connect to a SQL Server database on Server B.

In IIS on Server A, I have created a virtual directory called gdoc. For Directory Security I am using Integrated Windows Authentication. When I try to access the application, I get the following error:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
/gdoc/properties/GDocProperty.asp, line 23


When I change IIS to allow anonymous access the error changes to:

Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
/gdoc/properties/GDocProperty.asp, line 23

Line 23 corresponds to the connection string, which is coming from a .udl file. In the .udl the connection string looks like this: Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=GDoc;Data Source=TERRATAX

If I set up my web app on Server B then everything connects fine. It's running the web app on a different server that presents the problem.

This seems like it should be fairly routine, but I can't seem to figure out what I need to do.
The web app is NOT ASP.NET. It's classic .asp.

The reason for this is that the account you are using to connect to Server B(the one running SQL Server) is the IUSR_computernameServerA account (if this were ASP.NET, then the account is the ASPNET), which is the account used when you set IIS to anonymous access. In order to connect to SQL Server from Server A to Server B, you need to create an account named IUSR_computernameServerB on Server B and give this account permissions to access SQL Server. Or, better yet, use SQL authentication. Configure your SQL Server to use SQL authentication then create a SQL account and give that account permissions to the corresponding database. Then, in your connection string, use the credentials of the SQL account.

Hope this helps.|||I tried adding the account to SQL Server, but this is what I get this:

Windows NT User or Group '[domain name]/IUSR_TERRAGIS' not found.|||Have you tried SQL Authentication?

No comments:

Post a Comment