Welcome to MSDN Blogs Sign in | Join | Help

Jeff Nuckolls {Application Platform and Development Tools}

Here you'll find a little of everything as it relates to the Microsoft Application Platform (Biztalk, Visual Studio Developer tools, SQL Server, Windows, .NET development/architecture, etc...). I may even touch on WSS/MOSS from time-to-time. While my blogs are widely applicable to all verticals, I'm dedicated to the Education vertical (K-12 and Higher Education).
ASP.NET Error Message: Login failed for 'NT AUTHORITY\NETWORKSERVICE'

If you are developing against a local SQL Server 2005 database in Visual Studio you may not notice this error message until you attempt to access an ASP.NET page that attempts to read or write to your database from an external client (or browser not launch via VStudio)... the reason is because VStudio runs with elevated administrative previledges on the local dev machine.  While there are several ways to surpress this error, here are a few options you might consider:

 

  1. Modify the Web.config file to impersonate a user that has appropriate previledges for read/write access to your database.
    <system.web>
             <identity impersonate="true" userName="username" password="password" />
    <system.web>

    So you might have noticed that this is a little concerning... putting username/password in the web.config, but you can chose to encrypt this to make it more secure.  Otherwise try option #2.
  2. Open SQL Server Management Studio and grant the 'NT AUTHORITY\NETWORK SERVICE' account to the Role Membership of db_datareader and db_datawriter.
  3. A better option yet would be to force the user to login either via forms-based login or windows-based login and use ASP.NET Membership to control authentication to the site... ensure that appropriate users then are associate with a group that then has reader/writer permission on the database.  See here for details: http://msdn2.microsoft.com/en-us/library/yh26yfzy.aspx

Get-R-Done!

Posted: Monday, March 31, 2008 12:06 PM by jeffnuck
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker