Problem with SQL Server 2005 and IIS 6.0

Hello,

I am having problems with my system configuration. I am trying to access a SQL Server 2005 database from a C# .NET web page, but I keep getting this error, "Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'".I am using windows authentication. The SQL Server resides on one server and my web server is on a different server. If I run the both the web server and SQL Database from within the same server it works fine, the problem comes when I separate the servers.

I am running Windows Server 2003 on both servers, MS SQL Server 2005, MS Visual Studios 2005, and IIS 6.0.

Here is my Web.Config file:

<?xmlversion="1.0"?>

<configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<connectionStrings>

<addname="MyConnectionString"connectionString="Data Source=MYSERVER;Initial Catalog=mydatabase;Integrated Security=SSPI"

providerName="System.Data.SqlClient"/>

</connectionStrings>

<system.web>

<customErrorsmode="Off"/>

<compilationdebug="true">

<assemblies>

<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

</assemblies>

</compilation>

<identityimpersonate="true"/>

<authenticationmode ="Windows"/>

<authorization>

<denyusers="?"/>

</authorization>

</system.web>

</configuration>

Any comments or suggestions would be greatly appreciated.

Thank you,

Inti

[9580 byte] By [inti] at [2007-12-25]
# 1

Hi,

It's either the account that you are using in the webserver isn't valid to access sql server in the other computer. So I would suggest on creating a user in the SqlServer and changing your conneciton string to this:

"Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=myUsername;Password=myPassword;"

cheers,

Paul June A. Domag

PaulDomag at 2007-9-3 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 2


The below link should help. You're being tripped up by the the double-hop issue and the delegation of credentials to SQL Server is failing.

How to configure an ASP.NET application for a delegation scenario

PaulPClementIV at 2007-9-3 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 3

Thanks Paul,

I read a similar article about delegation, but I was wondering if there is a way to achieve without the installation of Active X.

Thanks again, Inti.

inti at 2007-9-3 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...
# 4


I'm not sure what you mean by Active X. Do you mean Active Directory?

For trusted/Windows integrated security across computers you need to enable Kerberos. Otherwise, you need to use a different authentication method (such as Basic) for your web application when using trusted security with SQL Server. The only other option (using integrated security) would be to run your SQL Server on the same machine as the web server.

PaulPClementIV at 2007-9-3 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified