Solved

Problem with SQL now site is published

Posted on 2006-11-24
8
220 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now