Friday, March 30, 2012

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Hi ,
I am using IIS 6.0 and have an ASP.NET where get the following error when
trying to connect from a .NET assembly.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
So I read some info from other forums and understand that I must add
the 'NT AUTHORITY\NETWORK SERVICE' as a user on my SQL Server 2005 database.
My problem is when I try to add this user by browsing for "Objects" in
Windows Server 2003, I don see this object. What am I missing?
Any ideas?By the way, my connection string is
"data source=NDS2214;Initial Catalog=UATP;Integrated Security=true"
"Opa" wrote:

> Hi ,
> I am using IIS 6.0 and have an ASP.NET where get the following error when
> trying to connect from a .NET assembly.
> Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
> So I read some info from other forums and understand that I must add
> the 'NT AUTHORITY\NETWORK SERVICE' as a user on my SQL Server 2005 databas
e.
> My problem is when I try to add this user by browsing for "Objects" in
> Windows Server 2003, I don see this object. What am I missing?
> Any ideas?

Login failed for user NT AUTHORITY\NETWORK SERVICE.

OK I know that this topic seems like it has been beaten to death in the forums but I'm still unable to figure out why I'm getting this error.

I've added the NT Authority\Network Service to the SQL server and the database that I want to connect to. I've made it the db_owner. Still got the error.

I added myself (the account I login with into windows) with the same options as with the NT Authority. Still got error.

I'm runnin SQL Server 2005 on my local machine as well as IIS 6. I know that my web.config is correct because I only started getting this error after I reinstalled SQL Server and IIS. I've really run out of ideas of why this is happening. I'm assuming from the error message that it's at the database level but I just don't know where.

Here are exerts from my web.config that may help:

<connectionStrings>

<removename="database"/>

<addname="database"connectionString="Data Source=(local);Initial Catalog=TheBugZoo;Integrated Security=True;"providerName="System.Data.SqlClient"/>

</connectionStrings>

<roleManagerenabled="true"cacheRolesInCookie="true"cookieName="TBZROLES"defaultProvider="TBZ_RoleProvider">

<providers>

<addconnectionStringName="database"applicationName="/"name="TBZ_RoleProvider"type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

</providers>

</roleManager>

Look at this KB article:http://support.microsoft.com/kb/316989|||

Hi,

Thanks for your reply. I ended up creating a user in the db and changing my connection string not to use the integrated security. This solved my problem but I still don't understand why I was having issues with the integrated security.

Thanks.

Login failed for user NT AUTHORITY\NETWORK SERVICE.

I've tried to use Windows authentication to connect to database in MS SQL Server 2000, my connection string like below:
"server=(local);Initial Catalog=myDatabase;Trusted_Connection=yes"
when I run my code, there is an error occur with below message:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
My SQL Server is configured as Window authentication.
I can't resolve this problem.
Please whow me how to do!
Thank you very much!
You either need to grant the Network Service account access rights toSQL Server, or your application needs to impersonate a specific Windowsuser that has rights to the database.

Login failed for user NT AUTHORITY\NETWORK SERVICE.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

I've just installed Windows Server 2003 and can't get past this.
I've changed the <processModel> userName to SYSTEM, I've added ASPNET to the Admin group, other tweaks with reboot but still can get it to work.
I'm not sure what the NT AUTHORITY domain is.

Anyone experience this?
Thanksok, looks like I figured it out. It works anyhow.
In the IIS Manager, I right clicked the Application Pools/DefaultAppPool node and hit properties.
I went to the Identity tab and for Predefined I selected Local System.|||Rex,

you saved me from near insanity....
I had installed tweeked...and gone over everything I could think of without any luck. Your one click solution did it. I guess I was trying to outsmart it all and fell on my face...

thanks a million,
Marc|||Thanks for this message, i can stop pulling my hair out now :-)|||This saved me alot of headaches too. But it also introduced one. You get a message that you are exposing IIS to attack and compromising sercurity.

Can someone explain how it should be done? I would like to be able to configure IIS to run with the minimal security needed to support ASP.NET pages and SQL Server access; but I do not have a clue what privilages and permissions would be needed.

Bill|||We were just chatting about this recently:view post 475172

(You can avoid the specific advice I gave because it wasn't particularly good :-) )

Terri|||The CGN IT article was exactly what I was looking for. Thanks.|||

tmorton:

We were just chatting about this recently: 475172 (You can avoid the specific advice I gave because it wasn't particularly good :-) ) Terri

This link is now dead, makes sinces since its from 2004. Anyone know where I can find the article now?

Thanks

|||

john.lieurance@.flhosp.org:

tmorton:

We were just chatting about this recently: 475172 (You can avoid the specific advice I gave because it wasn't particularly good :-) ) Terri

This link is now dead, makes sinces since its from 2004. Anyone know where I can find the article now?

Thanks

You can use the post ID from that link and surmise the new link:http://forums.asp.net/thread/475172.aspx

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

sql

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

I have:

(1) SQL 2005 on a member server, Windows Authentication

(2) I'm using Visual Studio.Net 2005 on my Windows XP sp2 work station.

(3) From my machine, within my development application, I have no problem accessing the Data in the SQL server.

(4) I Receive the Login Failed error after I copy my project to the Test Web Server (Same machine that houses SQL) and test from either my machine or from the host server.

More details of the error message are:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

Source Error:


Line 33: DA = New SqlDataAdapter(sSql, CONN_STRING)
Line 34: DS = New DataSet
Line 35: DA.Fill(DS)
Line 36:
Line 37: Session("NameInquiry_DS") = DS

Source File: C:\Inetpub\wwwroot\nameinquiry\NameInquiry.aspx.vb Line: 35

The finished product is to be an Intranet site only; accessible by employees within our own private network.

The SQL is a new install with only test data.

What have I missed that is causing the permission problem? The event viewer shows a nonauthenticated user is causing the problem. But, how do I correct this?

Could you please post the connection string here and the part of the web.config file about impersonation (if any and not commented out). This is a configuration problem. Which user do you want to authenticate while connecting to the database ?

http://msdn2.microsoft.com/en-us/library/aa302377.aspx

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Hi, Terry

Try to read following article, they probably include solution to your problem:

1) http://support.microsoft.com/kb/316989/

2) https://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=348662&SiteID=17

3) http://msdn2.microsoft.com/en-us/library/ab4e6cky(vs.80).aspx

Good Luck!

Ming.

|||

Here is my connection string and the Web.Config.

What is confusing is that I have zero issues running the application within VS ASP.NET. It's only when I run the application outside the development software.

When I check the Event Viewer on the server that houses SQL, the login name is blank. That's why I believe I have a permissions error. I just don't have any idea what permissions to set. It doesn't matter which desktop I use, the connection fails. If I try to access the website from the Server it's housed using the administrator login, I still get the Login failed message.

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

<appSettings>
<add key="ConnStringer" Value="packet size=4096;Data Source=MYSERVER;Initial Catalog=MyDataBase;Integrated Security=True;"/>
</appSettings>

<connectionStrings>
<add name="myConnection" connectionString="server=MYSERVER;database=MyDataBase;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<authentication mode="Forms" />
<roleManager enabled="true" />
<compilation debug="true" strict="false" explicit="true"/>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

-->

<anonymousIdentification enabled="true"/>
<profile enabled="true">
<properties>
<add name="myGroupID" allowAnonymous="true"/>
<add name="myUserID" allowAnonymous="true"/>
</properties>
</profile>


</system.web>
</configuration>

|||

Ming,

The articles were very informitive but none of the possible solutions resolved my problem.

In an earlier post, I stated that everything worked fine within my VS .NET application. I have since learned that as long as I view data only, it works. If I attempt to do any writes, the application fails. Therefore, I'm more convinced this is an authentication related issue. Now I'm asking the following questions as I try to locate and resolve this issue:

I have determined that NT AUTHORITY\NETWORK SERVICE is the default login when I run my application. Based on what I've read from the many web posts concerning Windows Authenticaion, this is normal. How do I control the default login name? Meaning, can this be changed? If so, How? Should it be changed? Can I set various permissions to the various SQL databases? If so, How?

|||

Are your client and server machine in WORKGROUP instead of domain? If so, can you try grant database login to "<machinename>\guest" see whether it works?

As for your questions that how to control default login name, it is more of ASP.NET configuration issue, such as you can change ASP.NET account( http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount)

or post your question in ASP.NET forum.

The workaround here is

1) Change your connection string to force tcp connection(adding prefix "tcp:" in DataSource field ).

2) Use SQL authentication.

Good Luck!

Ming.

|||


Hi,

using Anonymous authentication will make you able to use a single user connecting to the database. This uer has to be setup in the security tab of the website in the IIS configuration screen. If you want to use this combination, you will have to set the tag of the web.config to impersonate=true. This will let you use login procided within the IIS to access SQL Server. If you want to authenticate / impersonate the user which is currently accessing the web page, you will have to (assuming that the web server is on the same server as the SQl Server) disbal the anonymous access option in the IIS configuration dialog.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

I think that the 3rd of Ming's posts alludes to the potential problem and provides links to additional relevant info (and your hunch about authentication related issue would also be accurate). The most likely source of the problem, as Ming and Jens have pointed out, is impersonation.

NT AUTHORITY\NETWORK SERVICE is the account that IIS runs under on Windows Server 2003 and without any additional configuration, this is the account that will attempt to access whatever resources the web application needs. Since this is the account that is trying to access the database, it appears that the outbound attempt is not attempting the connection as the connected user. This is where the web.config settings that Jens mentioned come into play and there's a good synopsis of the options available on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP05.asp (this looks identical to the link Jens posted earlier). You probably don't need or want IIS to run under a different account.

If you want each domain user to have a separate connection to the database, you will need to disable Anonymous Access and turn on Integrated Windows authentication (this would be on the Directory Security tab for the web site in IIS Manager). You'd then specify <identity impersonate="true"/> in your web.config. You may also want to change the <authentication> element to be mode="Windows"...check with MSDN and or the ASP.NET forum for additional info/guidance on the specifics there, as I'm well outside my area of expertise on that point.

If you want all DB access to route through a single connection (I'm not entirely sure that's advisable, but your circumstances may dictate this) and/or as a single user (also not advisable...auditability of data written to the database would be compromised, so you wouldn't be able to determine who made a given change), you could continue to use Integrated Windows authentication on your web app but change the web.config to be:

<identity impersonate="false"/>

<authentication mode="Windows"/>

You'd then provide access to the SQL Server table via one of the server roles for the NT AUTHORITY\NETWORK SERVICE account. An example would be to use sp_addrolemember to add this account to public and grant public insert and update permissions on these tables (if it doesn't have them already).

There is a "How To" article on these options available at: http://msdn2.microsoft.com/en-us/library/ht43wsex(VS.80).aspx

Good luck,

Jason

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

sql

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Any help would be very very much appreciated as I am about 15 hours into this :(

Background is a development system with ASP.NET 2.0 and SQL express 2005. The server is SQL 2005 standard edition. Any ASPX pages that connect to a database results in errors.

I have 2 identical servers with Windows server 2003, one has SQL Express and the other has SQL Server 2005 standard. that is the only difference between these systems. The scripts that work seamlessly when uploaded to the SQL Express server dont work on the SQL Server 2005

My connection string is

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Datasource=servername;Integrated Security=SSPI;initial catalog=C:\INETPUB\WWWROOT\test\app_data\aspnet.MDF;"
providerName="System.Data.SqlClient" />

two interesting tidbits

1.) No matter what the initial catalog is pointing to, I get the same error. EVEN if the database doesnt exist

Cannot open database "C:\INETPUB\WWWROOT\test\app_data\aspnwet.MDF" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

2.) second interesting thing is this, if I change the datasource to "MSSQLSERVER" which is the instance name of SQL 2005. the error changes to

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

I have reinstalled SQL server 2005

I have verified that under SQL Server 2005 Surface Area Configuration that remote connections has Both TCP and Named Pipes enabled

I have verified that under the Network Configuration that the protocols for TCP/IP and Named pipes are enabled.

I have tried atleast 20 different variations of Connectionstrings

I have ran aspnet_regsql against the database

I have verified that the SQL Server Browser is started

I have verified that the TCP/IP is set in Network Configuration to default port 1433

I have gave all authentication rights to Network Service and ASPNET accounts for testing against both the MASTER and ASPNET databases using Management Studio and attaching the Database

I have created a custom SQL account with access to the database in question and added the username password syntax to the connectionstring and get the same login failed message.

If anyone can give any insight that would be MUCH appreciated!! thanks in advance.

Akiren.

(1) You are failing on user permission check to sql server as whole not individual database, so no matter what catalog your refering to. I assume the sql server is running on a local machine. This is a IIS and ASP.Net configuration issue, I would recommend you to check with ASP.NET forum and IIS forum w.r.t connection authentication to sql server. I think you probably need to set connection impersonation in IIS or ASP. Also, you can check SQL security forum. There is a difference that special to sqlexpress in authenticate user connections.

(2) datasource, if it is not (local), "." or "<empty", it will be refer to as <servername>[\<instancename>]. In your case, MSSQLSERVER is not a valid <servername>, so the connection string does not work.

|||

Its not an IIS or ASP.NET configuration issue as far as I can tell. Even if I goto the command prompt and type

sqlcmd -s SQLINSTANCE -e

I get the same named pipes sql server does not allow remote connections. The SQL Server is local.

One interesting tidbit, whenever I try to put SERVERNAME\INSTANCE in the connection string or even dos I get an invalid connection string.

|||

Maybe I didn't explain to you clearly.

The item(1) was to your first issue, and (2) was to your second issue. Your first issue looks like a ASP/IIS issue. The second issue is because you are composing a connection string that does not point to a real server.

Is SQLINSTNACE your machine name?

For the default instance, you can use <machinename>,

For nameinstance, you can use <machinename>\<instancename>.

|||

Hi Akiren,

How are you?

There are only two solutions to your problem.
1. Close the MS Visual Studio (it will stop the SQL express) and run your application via IE (assuming that the you've configured your Virtual directory).
2. Detach from SQL Express and transfer your DB to other SQL Server 2005 edition.

SQL Server Express Edition allows only a single connection to an .mdf file


Erwin De Leon
www.mrwebservice.net

|||

Hi,

You′ve to change "Integrated Security=SSPI" to "Integrated Security=false";

I think it will fix it!

[]′s Breno

|||

This is an internal acct that is not displayed in user manager - you can't depend on a GUI....

submit this line into query analyzer on master or your database to grant access:

sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

Its scary to read about the security holes people opened up through ignorance in this blog

|||Hi. I am having the exact same problem! I tried all the solutions presented and still no luck. I have the small business starter kit installled on Win2k Adv Srvr where I have trial Studio Web Express w/SQL express no problems. Move it to a Small Business Server change the .\SQLExpress to the localhost server name ( server11 ) no problem. Move it out to a site with SQL 2005 trial, try every connection string possible and all the blog solutions - no luck. Did you ever get a working solution? Thanks ... I'm pretty new the developer scene but pretty saavy.|||

Hi Juan,

You are probably having problems because your SQLServer Security is not well-configured.

Try to check your confs again... on Security.

|||Thanks. I added the NT AUTHORITY\NETWORK SERVICE user to the database and gave it all the permissions I could see through SQL Management studio. Did the grant login recommended etc. I thought I tried all possible. I am guessing that you are correct. There is no sensitive information on this server, so I haven't gotten into tightening security. The personal web page starter kit, with some changes, runs fine on the same server. I guess I could go XML with the Small Business Starter kit, but that would be whimping out I think! Anything more specific would be helpfull. Thanks again.|||

hi Akiren

i was facing the same problem but then after changing my connection string to following it was done correctly.

<remove name="LocalSqlServer" />

<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=Track;user id=sa;password=agile;" providerName="System.Data.SqlClient"/>

Please check your LocalSqlServer string again, provide userid, password for connecting sql server.

|||

tommy123456 's method has solve my the same problem

|||

I got almost frustrated last night, trying to get things working (setting up permisssions in sqlexpress etc.). Finally this morning, success!

I must have some type of error writing connection strings:

Now it works with both:

either

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;

or

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

Allelujah!

|||G Jovan's second connection string (sql) just worked fine for me. But I wonder why first one (windows) is not working. I am still getting Login failed for user 'NT AUTHORITY\NETWORK SERVICE' no matter what you already suggested. I will appreciate very much if one can post another advice for the solution.|||

Hi

My problem has been solved by the following method:

Add permissions to 'NT AUTHORITY\NETWORK SERVICE' in the security folder of your SQL 2k5 express.

sql

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

I have:

(1) SQL 2005 on a member server, Windows Authentication

(2) I'm using Visual Studio.Net 2005 on my Windows XP sp2 work station.

(3) From my machine, within my development application, I have no problem accessing the Data in the SQL server.

(4) I Receive the Login Failed error after I copy my project to the Test Web Server (Same machine that houses SQL) and test from either my machine or from the host server.

More details of the error message are:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

Source Error:


Line 33: DA = New SqlDataAdapter(sSql, CONN_STRING)
Line 34: DS = New DataSet
Line 35: DA.Fill(DS)
Line 36:
Line 37: Session("NameInquiry_DS") = DS

Source File: C:\Inetpub\wwwroot\nameinquiry\NameInquiry.aspx.vb Line: 35

The finished product is to be an Intranet site only; accessible by employees within our own private network.

The SQL is a new install with only test data.

What have I missed that is causing the permission problem? The event viewer shows a nonauthenticated user is causing the problem. But, how do I correct this?

Could you please post the connection string here and the part of the web.config file about impersonation (if any and not commented out). This is a configuration problem. Which user do you want to authenticate while connecting to the database ?

http://msdn2.microsoft.com/en-us/library/aa302377.aspx

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Hi, Terry

Try to read following article, they probably include solution to your problem:

1) http://support.microsoft.com/kb/316989/

2) https://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=348662&SiteID=17

3) http://msdn2.microsoft.com/en-us/library/ab4e6cky(vs.80).aspx

Good Luck!

Ming.

|||

Here is my connection string and the Web.Config.

What is confusing is that I have zero issues running the application within VS ASP.NET. It's only when I run the application outside the development software.

When I check the Event Viewer on the server that houses SQL, the login name is blank. That's why I believe I have a permissions error. I just don't have any idea what permissions to set. It doesn't matter which desktop I use, the connection fails. If I try to access the website from the Server it's housed using the administrator login, I still get the Login failed message.

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

<appSettings>
<add key="ConnStringer" Value="packet size=4096;Data Source=MYSERVER;Initial Catalog=MyDataBase;Integrated Security=True;"/>
</appSettings>

<connectionStrings>
<add name="myConnection" connectionString="server=MYSERVER;database=MyDataBase;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<authentication mode="Forms" />
<roleManager enabled="true" />
<compilation debug="true" strict="false" explicit="true"/>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

-->

<anonymousIdentification enabled="true"/>
<profile enabled="true">
<properties>
<add name="myGroupID" allowAnonymous="true"/>
<add name="myUserID" allowAnonymous="true"/>
</properties>
</profile>


</system.web>
</configuration>

|||

Ming,

The articles were very informitive but none of the possible solutions resolved my problem.

In an earlier post, I stated that everything worked fine within my VS .NET application. I have since learned that as long as I view data only, it works. If I attempt to do any writes, the application fails. Therefore, I'm more convinced this is an authentication related issue. Now I'm asking the following questions as I try to locate and resolve this issue:

I have determined that NT AUTHORITY\NETWORK SERVICE is the default login when I run my application. Based on what I've read from the many web posts concerning Windows Authenticaion, this is normal. How do I control the default login name? Meaning, can this be changed? If so, How? Should it be changed? Can I set various permissions to the various SQL databases? If so, How?

|||

Are your client and server machine in WORKGROUP instead of domain? If so, can you try grant database login to "<machinename>\guest" see whether it works?

As for your questions that how to control default login name, it is more of ASP.NET configuration issue, such as you can change ASP.NET account( http://www.bluevisionsoftware.com/WebSite/TipsAndTricksDetails.aspx?Name=AspNetAccount)

or post your question in ASP.NET forum.

The workaround here is

1) Change your connection string to force tcp connection(adding prefix "tcp:" in DataSource field ).

2) Use SQL authentication.

Good Luck!

Ming.

|||


Hi,

using Anonymous authentication will make you able to use a single user connecting to the database. This uer has to be setup in the security tab of the website in the IIS configuration screen. If you want to use this combination, you will have to set the tag of the web.config to impersonate=true. This will let you use login procided within the IIS to access SQL Server. If you want to authenticate / impersonate the user which is currently accessing the web page, you will have to (assuming that the web server is on the same server as the SQl Server) disbal the anonymous access option in the IIS configuration dialog.

HTH, Jens K. Suessmeyer.


http://www.sqlserver2005.de

|||

I think that the 3rd of Ming's posts alludes to the potential problem and provides links to additional relevant info (and your hunch about authentication related issue would also be accurate). The most likely source of the problem, as Ming and Jens have pointed out, is impersonation.

NT AUTHORITY\NETWORK SERVICE is the account that IIS runs under on Windows Server 2003 and without any additional configuration, this is the account that will attempt to access whatever resources the web application needs. Since this is the account that is trying to access the database, it appears that the outbound attempt is not attempting the connection as the connected user. This is where the web.config settings that Jens mentioned come into play and there's a good synopsis of the options available on http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/SecNetAP05.asp (this looks identical to the link Jens posted earlier). You probably don't need or want IIS to run under a different account.

If you want each domain user to have a separate connection to the database, you will need to disable Anonymous Access and turn on Integrated Windows authentication (this would be on the Directory Security tab for the web site in IIS Manager). You'd then specify <identity impersonate="true"/> in your web.config. You may also want to change the <authentication> element to be mode="Windows"...check with MSDN and or the ASP.NET forum for additional info/guidance on the specifics there, as I'm well outside my area of expertise on that point.

If you want all DB access to route through a single connection (I'm not entirely sure that's advisable, but your circumstances may dictate this) and/or as a single user (also not advisable...auditability of data written to the database would be compromised, so you wouldn't be able to determine who made a given change), you could continue to use Integrated Windows authentication on your web app but change the web.config to be:

<identity impersonate="false"/>

<authentication mode="Windows"/>

You'd then provide access to the SQL Server table via one of the server roles for the NT AUTHORITY\NETWORK SERVICE account. An example would be to use sp_addrolemember to add this account to public and grant public insert and update permissions on these tables (if it doesn't have them already).

There is a "How To" article on these options available at: http://msdn2.microsoft.com/en-us/library/ht43wsex(VS.80).aspx

Good luck,

Jason