Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem with SQL now site is published

Posted on 2006-11-24
8
Medium Priority
?
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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 1000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

610 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