Solved

Problem with SQL now site is published

Posted on 2006-11-24
8
222 Views
Last Modified: 2010-04-06
Hi all,

I have had similar problems with his before when uploading a site with a database.  I have a single page site that has a SQL connection to a SQL 2000 database.  Nothing complicated at all.  The site works fine locally on my machine when I run it, but when published to either my local IIS 5 server or my companies II6 server I get the following message when opening the page.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

This is my connection string from within the web.config file:
<add name="CReqDBConnectionString" connectionString="Data Source=EQ-WEB01;Initial Catalog=CReqDB;Integrated Security=True"

And this is it within the SQLDataSource Control on the page:
Data Source=EQ-WEB01;Initial Catalog=CReqDB;Integrated Security=True

Thanks for all your help
0
Comment
Question by:2326ac
  • 3
8 Comments
 
LVL 29

Expert Comment

by:Nightman
ID: 18006343
You need to use impersonation in the web.config file. Have a look at http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/ASP_DOT_NET/Q_22070218.html
0
 

Author Comment

by:2326ac
ID: 18006391
Thanks for the quick reply, so is it just as case of pasting

<system.web>
<identity impersonate="true" userName="WindowsDomain\YourUserName" password="YourPassword" />
</system.web>

into my config file?  Adding my user name and password of course
0
 
LVL 29

Accepted Solution

by:
Nightman earned 250 total points
ID: 18006424
Only if you want to impersonate with a specific user.
If you want to use normal Windows Authentication (i.e. the user that is connecting to the web sites credentials) then you just do:

<system.web>
<identity impersonate="true"/>
</system.web>
0
 
LVL 11

Assisted Solution

by:AlexanderR
AlexanderR earned 250 total points
ID: 18012489
Just a thoughed...

When i tried to run an application that uses a MySQL database not on the same computer that MySQL is running, i had to explicitly allow YourUserName to connect from a particular computer. In another words MySQL does not allow just any computer to connect to it but only those that are allowed in the administration.

Can your SQL2000 possibly be the same way, not allowing computer that you publish your stuff on to connect to itself??
0
 
LVL 29

Expert Comment

by:Nightman
ID: 18012502
Yes. Either you need to connect with a specific MSSQL user in the connection string (and this would obviously have to have been created on the SQL Server) OR with Windows Authentication.

Using Windows Authentication, the windows account used is by default 'NT AUTHORITY\NETWORK SERVICE'. You can't grant this user access on another server (as it is local to the web server) BUT you can use impersonation. Using impersonate = true (without a specific account) will force the web server to connect to the database server using the windows account of the user connecting to the web site. This obviously is only useful when you can be sure that all users have an account on the domain.

Using a specific account in the web.config means that the users will all connect to SQL Server (and in fact any other network resources) as the specified user, and not the user loggin in or the Network Service.

And best practice is to have the database server on a different machine to the web server (obviously if budget allows)
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
xml attribute DTD attribute differences 3 71
Collapseable list of URLs. 10 130
Tool to email me when a website changes 29 128
Grunt Copy file to another destination. 1 35
Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question