Friday, March 30, 2012

Login failed for user NT AUTHORITY\NETWORK SERVICE

I cant seem to deploy a DB to my server. Can anyone actually help with this? I have been goint through lots of different things to get it to work...

So far I have added the network service account to SQL Express 2005 through the express managment console I have also given NETWORK SERVICE explicit permissions on the database files themselves.

It works great on my dev box. I'm able to login and access my secondary DB but when i try to push the site to my server this is what happens. Any help on this is great -- if you need me to post any more of my code -- no problem

This is my exact error:

SqlException (0x80131904): Cannot open user default database. Login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.]

My web.config file looks like:

<!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --><configuration><appSettings/><connectionStrings> <add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\igx-ma.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" /> </connectionStrings><system.web><!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. Visual Basic options: Set strict="true" to disallow all data type conversions where data loss can occur. Set explicit="true" to force declaration of all variables. --> <identity impersonate="true"/> <authentication mode="Forms" /> <authorization> <deny users="?" /> <allow users="*" /> </authorization> <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> --> <membership> <providers> <remove name="AspNetSqlMembershipProvider"/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> </providers> </membership></system.web></configuration>

Network Service permission on your computer is different than network service on the server machine. You have given your machine's network service user permission but not given the server machine's network service user permission. Please go over to the server machine and give network permission from that machine.

|||

I should note that all things that I have tried have been from and for the server. My development work station has worked correctly from the begining.

I have only made changes on my server.

|||

Any one else have any advice on this?

|||

Hi swiil,

but when i try to push the site to my server this is what happens......

After you have put your site to the sever, does your database reside in the same machine as your application?

Also, please verify the suggestiongatehyperion gave you. thanks

|||

The database does reside on the same machine as IIS and the application.

I added the specific user NT AUTHORITY\ NETWORK SERVICE to the server both through SSMSE and on the file itself. When I try to attach the database through SSMSE I get an error that the file is in use but I can't figure out by what.

I have also tried opening up remote connections through the Surface Area Configuration tool.


Chris

|||

The resolution:

I stopped IIS -

deleted the db files from the server

re-copy the db files from my dev machine

attach them using SSMSE then attach the IIS user as well as NETWORK SERVICE user to the db directly.

Set those users as DB owners in SSMSE.

After that had to remove the line from my web config that said identity impersonate = true

Detached the DB's started IIS and everything worked as promised.

I Hope this helps someone!

No comments:

Post a Comment