Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 6 of 6

Thread: Login for user 'NT AUTHORITY\NETWORK SERVICE'

  1. #1
    newuser is offline Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Default Login for user 'NT AUTHORITY\NETWORK SERVICE'

    I got a development environment working locally on XP, but after moving it to Server 2003 I'm getting this error:

    Cannot open database "AspDotNetStorefront" requested by the login. The login failed.
    Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
    Exception Details: System.Data.SqlClient.SqlException: Cannot open database "AspDotNetStorefront" requested by the login. The login failed.
    Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

    Using SQL Server 2005 Express. I've added NT AUTHORITY\NETWORK SERVICE as a login at the server level and as a user for the AspDotNetStorefront database.

    Here's my connection string from web.config:

    <add key="DBConn" value="Data Source=(local)\SQLEXPRESS;Initial Catalog=AspDotNetStorefront;Integrated Security=SSPI;Persist Security Info=True;Packet Size=4096"/>

    Any ideas?

  2. #2
    ASPDNSF Staff - Jon's Avatar
    ASPDNSF Staff - Jon is offline Senior Member
    Join Date
    Sep 2004
    Posts
    11,419

    Default

    Add Network Service to the db_owner database role.

    I know db_owner is probably overkill... db_datawriter may be enough.
    Jon Wolthuis

  3. #3
    newuser is offline Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Default

    Thanks, but I've already added NT AUTHORITY\NETWORK SERVICE as db_owner. Even tried adding MACHINENAME\IIS_WPG as db_owner too, but it's still not working.

  4. #4
    ASPDNSF Staff - Jon's Avatar
    ASPDNSF Staff - Jon is offline Senior Member
    Join Date
    Sep 2004
    Posts
    11,419

    Default

    SQL Mgmt Studio > Tools > SQL Server Profiler

    All the simple fixes have failed.
    Jon Wolthuis

  5. #5
    newuser is offline Junior Member
    Join Date
    Jun 2005
    Posts
    24

    Default

    Holy smokes thanks for that tip Jon!!! I spent the better part of a day trying to figure this out and never would have solved it without the Profiler. (Which I'd never used before, so double-thanks for turning me on to this tool!)

    The first line it gave me was "Error: 911, Severity: 16, State: 1", which I found this description of:

    This error occurs when attempting to change database context (with a USE statement) to a database that does not exist or when the default database established for a login does not exist.

    That helped me figure out the problem. When I created the AspDotNetStorefront database, I'd accidentally named it ' AspDotNetStorefront' (with a leading space). At some point I renamed it to get rid of the space, but that must have been after I'd already added the Network Service user and set it's default DB to the misspelled version with the leading space character.

  6. #6
    RyanS is offline Junior Member
    Join Date
    Sep 2010
    Posts
    8

    Default use the SQL Login connectionstring

    If the above tests do not work, try using the connectionstring in the web.config that uses a SQL Login username and password.