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

    Question

  • 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.

     

    Thursday, April 13, 2006 5:06 PM

Answers

  • 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>.

     

    Friday, April 14, 2006 2:02 AM

All replies

  • 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.

     

     

    • Proposed as answer by Kitano Thursday, April 29, 2010 3:41 PM
    Thursday, April 13, 2006 7:39 PM
  • 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.

    Thursday, April 13, 2006 8:29 PM
  • 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>.

     

    Friday, April 14, 2006 2:02 AM
  • 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

    Tuesday, August 15, 2006 10:20 AM
  • Hi,

     

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

    I think it will fix it!

     

    []´s Breno

    Thursday, December 07, 2006 11:17 AM
  •  

    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 

    • Proposed as answer by SScript Tuesday, February 07, 2012 2:30 PM
    Tuesday, December 12, 2006 4:25 PM
  • 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.
    Tuesday, January 02, 2007 8:18 PM
  • Hi Juan,

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

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

     

    Tuesday, January 02, 2007 8:36 PM
  • 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.
    Tuesday, January 02, 2007 8:48 PM
  • 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.

     

    • Proposed as answer by MITHUN MADDY Wednesday, April 25, 2012 7:08 AM
    Wednesday, March 07, 2007 12:42 PM
  • tommy123456 's method has solve my the same problem

    Tuesday, March 20, 2007 12:22 PM
  • 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!
    Sunday, April 01, 2007 8:31 AM
  • 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.
    Thursday, April 12, 2007 6:52 PM
  • 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.

    Tuesday, April 24, 2007 6:42 AM
  • Ok, I tried everything but what I kept missing was that the Initial Catalog is case-sensitive. I had moved the site to a customer location and they had different casing (same name) for the database. It solved my issue after hours and hours of trying things. Hope it helps someone.
    Saturday, June 30, 2007 9:41 PM
  • Thank you, thank you, thank you, tommy123456.  I've been beating on this all day and your solution works like a charm!  After running :

     

    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

     

    in query analyzer against both master and my database, and turning on Role Membership for all ASP roles plus db_datareader and db_datawriter, I finally got past that annoyning login failed error message.

     

    Thank you, thank you, thank you!

    • Proposed as answer by ronjayates5 Wednesday, November 17, 2010 7:44 PM
    Sunday, July 29, 2007 1:59 AM

  • I'm having the same problem with SQL Server Analysis Server. sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE' does not apply in this case. I have a web service that connects programmatically to it:
    conn = new SqlConnection(
               Settings.Default.Connection);
                conn.Open();

    The client is in a separate machine. If anyone can think of a way for it to work with
    SQL Server Analysis Server please reply. Thank you,

    GF

    Monday, November 12, 2007 6:48 PM
  • It has solved my problem in SQL Server 2000
    Hope it helps to you

     

    Please follow below steps :
    Please confirm the login [NT AUTHORITY/NETWORK SERVICE] is present under Security/Logins Node at SQL Server Instance
    Right Click on the user[NT AUTHORITY/NETWORK SERVICE] - Select Properties - Go to Database Access Tab - Check the desired database -
    Assign public - db_owner roles

     

    Click Ok,

    Refresh the database and Finally Try the Application once again.

    Hope it helps.

    • Proposed as answer by Mandar Patki Thursday, June 11, 2009 9:45 AM
    Monday, December 24, 2007 9:00 AM
  • Hi,

    My problem is wierd.

     

    I am trying to assign a user in my code to access my database but it keep defaulting to logging in as NT AUTHORITY/NETWORK SERVICE user.

     

    I have no idea why.

    1) This same user that am am assigning to another database works just fine.

    2) I have made sure both database contains same user access.

     

    My connection strings are as below. But I am being defaulted to NT authority when logging in to OpsTradingDB, Please advise.

     

    Thanks in advance.

     

    <connectionStrings>

    <add name="OpsTradingConnectionString" connectionString="Server=DEVPC;Database=OperationsTradingDB;User ID=PETREDECS\\AppAcc;Password=Pa$$w0rd;Trusted_Connection=True"/>

    <add name="EmployeeConnectionString" connectionString="Server=DEVPC;Database=EmployeeDetails;User ID=PETREDECS\\AppAcc;Password=Pa$$w0rd;Trusted_Connection=True"/>

    </connectionStrings>

    Tuesday, January 29, 2008 2:53 AM
  • submit this line into query analyzer on master or your database to grant access:

    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'



    Thanks Tommy123456, that did the trick for me.  I also had to open that user in SQL and point them towards the appropriate database for my particular case. 

     

    Friday, February 01, 2008 8:11 PM
  • Well I followed the instructions above; I am running sql server 2005 enterprise; below is my conncetion string:

     

    <add key="DatabaseProposals1" value="Provider=SQLOLEDB;Data Source=RGV-BOS-BL2;Database=Proposals;Integrated Security=SSPI;"/>
      

     

    Friday, February 15, 2008 3:50 PM
  • i also face the same problem, Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. i like to try with tommy's idea but how can i change the grant access for my aspnetdb database. i could not find it. i only have database master, model & tempdb. why my aspnetdb.mdf is not detected?.  i tested the connection at web admin tool. the connection is success.
     
    another wierd thing is i can view my page (client.aspx) using localhost but when i use IP address http://231.222.170.244/client.aspx, i got error login failed for user 'NT AUTHORITY\NETWORK SERVICE'. please help me to solve this. tQ 
     
    Wednesday, March 26, 2008 2:05 AM
  • Hi,

    I got help from someone who knows this stuff inside and out.  They pointed me to these two white papers.  Hope that it helps.

     

    The problem you are experiencing is an issue with how ASP.NET handles impersonation and access to remote resources.  One of the best solutions for this is to run your web service in the context of a domain user that has access to all the resources that are needed, and do not impersonate the client.  This means your domain user will need to have access to both the remote machine where it is creating directories and have access to the database to update records.

     

    This issue in ASP.NET is well discuss in these two documents, from identifying the issue of identity management to designing solutions based around the infrastructure in place:

    -          http://www.microsoft.com/technet/security/guidance/identitymanagement/idmanage/P3ASPD.mspx?mfr=true

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

    Wednesday, March 26, 2008 3:09 PM
  • if,  you acess it in system like intranet, then delete Intigrated Security from connection string or set it off and specify user id, password of sql-server authentication

     

    Monday, May 19, 2008 7:11 AM
  •  

    Thank you, thank you, thank you, tommy123456 and VegasDave.  The combination of your posts worked for me.
    Thursday, July 03, 2008 2:03 PM
  • Your connection string is wrong. Meaning you wanted to use SQL authentication but for some reason it is using Integrated Security  ....
    Saturday, July 05, 2008 8:16 PM
  •  VegasDave wrote:

    Thank you, thank you, thank you, tommy123456.  I've been beating on this all day and your solution works like a charm!  After running :

     

    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

     

    in query analyzer against both master and my database, and turning on Role Membership for all ASP roles plus db_datareader and db_datawriter, I finally got past that annoyning login failed error message.

     

    pls tell me  whatever  u did in  detailed procedure bcoz i am very  new  to  sql server  2000.

    Friday, August 01, 2008 9:58 AM
  • pls tell me this thing in detail procedure bcoz i am new to sql server 2000.
    Friday, August 01, 2008 10:13 AM
  • When you have created virtual directory of your application created in .Net2.0 and application is not running.
    Even everything is fine in web.config, still it is giving error in web.config file.
     
    Error :- The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.
     
    Solution is
    goto command prompt then navigate to directory
     
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
     
    Now run this command
     
    aspnet_regiis -ga "NT AUTHORITY\NETWORK SERVICE"
     
    Everything will wok fine.
    Wednesday, November 12, 2008 8:03 PM
  •  

    I think this is not a solution , because I would need to give different right of database accessing to the different users who connect to the web site.

    I  retrieve the user straight away from Windows authentication , so i need to give it an access to the database with his user and not 'NT AUTHORITY\NETWORK SERVICE' .

    Could someone help me?

    Wednesday, November 19, 2008 12:47 AM
  • Hi Closh,

    As per my experience ASP.Net is not able to get windows authentication till you have specified Impersonate. Even if we are maintaining Windows authentication at IIS level, I am not able to get Windows logon username when authentication is happening with Sql Server.

    If I really need to authenticate user under Windows in asp.net, Enable Impersonate as:
    <identity impersonate="true"
    userName="domain\user"
    password="password" />

    Now ASPNet will run under specified username instead of default ASPNET User Account (DomainName\MachineName).

    Try to understand

    ASP.NET Process Identity in http://msdn.microsoft.com/en-us/library/aa291350.aspx


    Thank You.
    Wednesday, December 17, 2008 9:56 PM
  • thanks thanks thanks Sidheshwar it worked for me.

    RS

    Tuesday, December 30, 2008 2:26 AM
  • Hi Cinni,

    Would you be more specific? my email is "Akshay Patel" ajade101@yahoo.com
    Monday, March 09, 2009 9:03 PM
  • This worked for me! Thanks! Only difference, I need to set the server role to 'sysadmin' for NT AUTHORITY/NETWORK SERVICE
    Developer
    Thursday, June 11, 2009 9:46 AM


  • I just have the same problem.
    And wants to use this solution, but DB Admin not allowed.

    Just make sure that
    Persist Security Info=True, when user & password need to be set.
    This works.

    It is better & secure way

     

    • Proposed as answer by faris sufyan Tuesday, July 28, 2009 7:08 AM
    Monday, June 29, 2009 3:26 AM
  • write below line in new query window


    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

    run it under your database and also under master


    On your Particular Database follow the below step

    go to security -> Users -> NT AUTHORITY\NETWORK SERVICE ->Right Click -> Properties -> Check datareader, datawriter

    • Proposed as answer by yousufkhan Thursday, October 01, 2009 8:09 PM
    Thursday, October 01, 2009 8:07 PM
  • .
    I give up... If this post does not result in a solution for me, I am dropping Microsoft SQLServer
    I have tried so many combinations, I don't know what is what anymore.
    My site connection worked great under WINDOWS XP Pro, I can't get it to work under WINDOWS 7 Pro
    Fails at the Conn.Open statement.

    My small contribution: (This maybe or may not be related, but a good thing to know)
    If anyone has had the nagging Visual Studio Debugger Timing out problem, here is what I ran into:
    If the DefaultAppPool in IIS7 is set to:
        - Managed Pipeline Mode=Integrated  (if change that to Classic ...debugger starts timing out again)
        - Identity=NetworkService  (if change that to LocalSystem ...debugger starts timing out again)
    the Visual Studio Debugger no longer times out after 1+ minute.

    THE MAIN ISSUE:
    I have WINDOWS 7 Pro
              IIS 7 and IIS7 Manager
              Visual Studio 2008
              SQLServer EXPRESS 2005
              SQLServer Express Management Studio.
              .NET Framework 2.xxx (3.5)

    Connecting to database via ASP.NET site fails:

    Many of the  options stated in above posts are not showing up on the WINDOWS 7 Pro, IIS 7, or the SQLServer Management Studio. I have to interpret them into what I see on WIN 7...
    I have created the NetworkService User in SQLServer and set Full COntrol on the rootFolder of the Website(Folder where the project resides... and it shows under IIS)
    My DB.mdf resides at: (I believe this is the 64-Bit side)
         C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB.mdf

    WINDOWS 7 Pro base:
    The MyDB.mdf and MyDB.ldf were copied from the previous XP Pro installation to this New WINDOWS 7 Pro setup.
    SQLServer Explorer in Visual Studio and SQLServer 2005 Management Studio BOTH connect and allow management of the database. no problems, NO MATTER WHAT CHANGES I MAKE TO IIS.

    If you say adjust this role to this and that... I will not know what it means.
    I need a step by step, go here, set to that type help. (Thank you)
    Will anyone please provide a simple list of all the settings that need to be addressed to establish a successful database connection/login via the website. The website functions smoothly in all respects except for the connection to the database.

    IIS 7:  DefaultAppPool, Advanced settings etc...

      I choose not to list all options to avoid confusion as to which should be addressed and which need not.
      Provide complete list and corresponding settings, please. (Thank you)

    SQLServer 2005 Management Studio...
    If you say adjust this role to this and that... I will not know what it means.
    I need a step by step, go here, set to that type help. (Thank you)

    Connection String tag=value list...
    I wanted to connect without using a user in the database(WINDOWS AUTHENTICATION I assumed) but I am starting to think it is not possible.
    What does the NetworkService connect to? SQLServer? ALL databases?
    Do I have to include My Windows Login account as a user in SQL?

    2 of the 50 scenarios I have tried:
    __________________________________________________________________
    AppPool Identity: NetworkService
    Managed Pipeline Mode: Classic (causes debugger to time out after 1+ minute!)
    <add connectionString="Server=MYCOMPUTER\SQLExpress;Database=MyDB.mdf;Integrated Security=true" name="MYWEBSITE.My.MySettings.ConnString" providerName=".NET Framework Data Provider for SQL Server" />
    Error:  Cannot open database "MyDB.mdf" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
    __________________________________________________________________
    AppPool Identity: NetworkService
    Managed Pipeline Mode: Integrated (Debugger no longer times out after 1+ minute, stays on till stopped)
    <add connectionString="Server=MYCOMPUTER\SQLExpress;Database=MyDB.mdf;Integrated Security=false" name="MYWEBSITE.My.MySettings.ConnString" providerName=".NET Framework Data Provider for SQL Server" />
    Error:  Login failed for user ''. The user is not associated with a trusted SQL Server connection.

    __________________________________________________________________
    AppPool Identity: NetworkService
    Managed Pipeline Mode: Integrated (Debugger no longer times out after 1+ minute, stays on till stopped)
    <add connectionString="Server=MYCOMPUTER\SQLExpress;Database=MyDB.mdf;Integrated Security=true" name="MYWEBSITE.My.MySettings.ConnString" providerName="System.Data.SQLClient" />
    Error: 
    Cannot open database "MyDB.mdf" requested by the login. The login failed.
    Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
    __________________________________________________________________
    AppPool Identity: NetworkService
    Managed Pipeline Mode: Integrated (Debugger no longer times out after 1+ minute, stays on till stopped)
    <add connectionString="Server=MYCOMPUTER\SQLExpress;Database=MyDB.mdf;Integrated Security=false" name="MYWEBSITE.My.MySettings.ConnString" providerName="System.Data.SQLClient" />
    Error:  Login failed for user ''. The user is not associated with a trusted SQL Server connection.
    __________________________________________________________________

    Thank you anyone in advance.
    .


    SPA
    Saturday, November 21, 2009 7:40 PM
  • write below line in new query window


    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'

    run it under your database and also under master


    On your MyDB in SQL Server Management Studio under Security tab do the following

    if a user like NT AUTHORITY\NETWORK SERVICE
    is not present

    if present db_datareader and db_datawriter must be checked

    security -> Users -> Right Click->  New User

    Write User Name and Login Name both as NT AUTHORITY\NETWORK SERVICE

    Dont forget to check db_datareader and db_datawriter both in Owned Schemas and Database role membership windows ->OK


    C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB.mdf
     
    Right Click the folder Data from above path

    Right Click -> Properties -> Security -> Edit ->Check Full Control for all Users

    Users like SYSTEM etc






    Monday, November 23, 2009 4:24 PM
  • THE PROBLEM IS AS SIMPLE AS FOLLOWS AFTER A MASSIVE AMOUNT OF TIME SPENT.

    GO TO CONTROL PANEL: ADMINISTRATIVE TOOLS: SERVICES: OPEN SQLEXPRESS

    CHANGE THE SETTING TO LOCAL ACCOUNT.

    THAT WORKS.

    Wednesday, December 02, 2009 7:57 PM
  • .
    I don't know why it swaps spaces with the A(circumflex) if you  do not sign in.
    When I sign in... they all are rendered as spaces... ??

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    *                                                                                                                       *
    *    Many THANKs to ALL FOR THE PROVIDED ANSWERS AND SUGGESTIONS     *
    *                                                                                                                       *
    *                                   I    A M    R U N N I N G                                                 *
    *                                                                                                                       *
    *     I am running, but see below, I included a CHART OF MY SETTINGS         *
    *     It is not as simple as just one or 2 fixes                                                 *
    *                                                                                                                       *
    *  [Q. ##] Questions are in red if this color survives                                              *

    *                                                                                                                       *
    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

    .
    yousufkhan, aliziveieLAPLACE777

    LAPLACE777
    [ THE PROBLEM IS AS SIMPLE AS FOLLOWS AFTER A MASSIVE AMOUNT OF TIME SPENT.
      GO TO CONTROL PANEL: ADMINISTRATIVE TOOLS: SERVICES: OPEN SQLEXPRESS
      CHANGE THE SETTING TO LOCAL ACCOUNT.
      THAT WORKS. ]
    ------------------------------------ My Response ---------------------------------------
    Q. 01 I believe that is how all the Microsoft Tools access the Database, but not
    via IIS/ASP.NET, but if you could enlighten me on your suggestion I would be glad
    to learn. T.Y.

    ------------------------------------------------------------------------------------------

    aliziveie
      aspnet_regiis -ga "NT AUTHORITY\NETWORK SERVICE"
    ------------------------------------ My Response ---------------------------------------
    I am afraid to even run that command
    Q. 02 Everything works except for the concurrent use issue mentioned below,
    therefore I do not believe I should run this command.
    Can you please confirm? T.Y.

    ------------------------------------------------------------------------------------------

    yousufkhan, T.Y. much for your post.
    BITTER SWEET RESULTs.   IT WOOOOOOORKS!!! but it FAILLLLLLS !!!
    .
    Before I read your post, yousufkhan
    I was successful in getting it to work, but I am not sure what actually got it to work.
    I am connecting via the website ASP.NET code, via the SQL Server Explorer in Visual Studio, and the SQL Server Management Studio tool.
    ...and more than I could expect, I also was able to connect to the HOST remotely with SQL Management Studio... all I had to do was to pluck in the server name and the user credentials and poof, magic, looking at database on Internet HOST, apparently with not a single problem...

    ...until I RAN INTO A NEW SNAG.
    I am not able to use either the website, Management Studio, or SQLServer Explorer at the same time.
    If I kick-in any 2 concurrently, I get that the datbase(MyDB.dbf) is currently in use by another application and cannot be accessed, Error 4064... and eventhough I may close one or both the apps, when I attempt again, the same error.
    If I Stop the SQLServer Service and reStart... I have access again.

    I think I read someone saying that SQLServer Express only allows one connectin at a time ???
    Note: on my MSDE(Vale Sofware) tool in the old XP setup, I was able to edit the database at will on multiple instances (CONCURRENTLY) no matter how many other apps were connected(CONCURRENTLY) to the database.
    NOT BEING ABLE TO DEBUG WHILE KEEPING AN EYE ON THE DATA CONCURRENTLY IS MURDER.

    Erorr Text: Cannot open user default database. Login failed.
    Login failed for user 'MyMachineName\MyWindowsUser'(me, administrator). (Microsoft SQL Server, Error: 4064)
    (Thank you Microsoft for producing Error dialogs WHERE THE BLANKING TEXT CANNOT BE CLIPPED!   GRRRRRR!!!!!!)

    Q. 03 Tell me that I will be able to have concurrent access or the saga ends here!


    Remember I am connecting/managing/updating just fine with ALL of the TOOLS!!!
    except for CONCURRENT access error listed above.

    yousufkhan,
    write below line in new query window

    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'
    run it under your database and also under master
    ------------------------------------ My Response ---------------------------------------
    I have access now(see the detailed layout below), thus I am not doing anything
    until I get a clear view of what each parameter I change does.
    Although I did not use the command sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'
    in a query window, I am sure that I granted login to the 'NT AUTHORITY\NETWORK SERVICE'
    somewhere in one of the dialogs.  There are so many places to set the parameters and no 2
    dialogs are laid out the same way of use the exact same nomenclature, it's hard to make sense of it all.
    Q. 04 Let me know if I still should execute the above script.
    ------------------------------------------------------------------------------------------

    yousufkhan,
    On your MyDB in SQL Server Management Studio under Security tab do the following

    if a user like NT AUTHORITY\NETWORK SERVICE

    is not present ??? OK I see now... that line should be swapped with the next one.
    if present db_datareader and db_datawriter must be checked
    security -> Users -> Right Click->  New User
    Write User Name and Login Name both as
    NT AUTHORITY\NETWORK SERVICE
    Dont forget to check db_datareader and db_datawriter both in Owned Schemas and Database role membership windows ->OK
    ------------------------------------ My Response ---------------------------------------
    under master security I have no
    'NT AUTHORITY\NETWORK SERVICE' see detailed layout below
    under MyDB security I have 'NT AUTHORITY\NETWORK SERVICE' with:
    Username: NetworkService
    Login name: checked but grayed out: NT AUTHORITY\NETWORK SERVICE
    Default Schema is : dbo
    db reader, db writer and dbo checked. in the role members
    The Owned Schemas area is grayed out... ?
    Q. 05 It works, so why adjust that area and how since grayed out?
             Will it resolve the concurrent use problem?

    ------------------------------------------------------------------------------------------

    yousufkhan,
    C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB.mdf

    Right Click the folder Data from above path
    Right Click -> Properties -> Security -> Edit ->Check Full Control for all Users
    Users like SYSTEM etc
    ------------------------------------ My Response ---------------------------------------
    That was done already:
    ALL USERS THAT COUNT HAVE FULL ACCESS:
     - NT AUTHORITY\NETWORK SERVICE
    ,
     - MyMachineName\MyWindowsUserName
    ------------------------------------------------------------------------------------------

    MY SETTINGs...
    ===========================================================================
    ALL WORKING FINE EXCEPT FOR CONCURRENT ISSUE mentioned above.
    ===========================================================================

    CONNECTION STRING I USE IN web.config

    -------------------------------------------------------------------------------------------------
    <add name="MyWebsite.My.MySettings.ConnString" connectionString="Data Source=MyPCName\SQLExpress;AttachDbFilename=&quot;C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data\MyDB.mdf&quot;;Integrated Security=True;User Instance=True;" />
    -------------------------------------------------------------------------------------------------
    (...appears to be a Windows Authentication string as no user credentials are stated, the system should pick up MyWindowsUserName and associate that to the special user NetworkService.)

    SQL Management Studio
        Registered Servers
            Database Engine
                MyMachineName\sqlexpress
    (right click on that to get properties)
                    Edit Server Registration Properties

    GENERAL TAB

    Server Name: MYMACHINENAME\SQLEXPRESS
    Authentication: Window Authentication
    Registered server name: mymachinename\sqlwxpress
    Registered server description: Local instance - 'mymachinename\sqlwxpress'

    Connection Properties TAB
    Connect to Database: <default>
    Network Protocol: <default>
    (all are enabled in the dropdown, Shared Memory, TCP/IP, Named Pipes, VIA, DON'T KNOW which it is using as default)

    master database
    My master database DOES NOT even have an 'NT AUTHORITY\NETWORK SERVICE'
    Database User - MyMachineName\MyWindowsUserName
    it has dbo, ... etc... and
        MyPCName\MyWindowsUserName with dbo the only checked option under role membeship, and that is all
        I have now set the db_datareader and  db_datawriter for both schemas owned by User and Role Members
        ...will test to see if that makes any difference.
    Q. 06 is there anything wrong here? even though everything works?
             Will that resolve the concurrent use problem?

    MyDB
    under MyDB security I have
    'NT AUTHORITY\NETWORK SERVICE' with:
    Username: NetworkService
    Login name(checked but GRAYED OUT): NT AUTHORITY\NETWORK SERVICE
    Default Schema is: dbo
    db_datareader, db_datawriter and dbo already checked. in the role members
    The Owned Schemas area is GRAYED OUT... ?
    Q. 07 is there anything wrong here?
             Will it resolve the concurrent use problem?

    SQL Management Studio
        Object Explorer  <---------------OBJECT EXPLORER
            MyDB.mdf
    (right click on that to get properties)
                Permissions (highlight)
                   view connections properties (ok)
                       view server permisions (gives error below)
    Error text:
    Cannot show requested dialog.
    ===================================
    Could not load file or assembly 'file:///C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlManagerUi.dll' or one of its dependencies. The system cannot find the file specified. (mscorlib)
    Q. 08 Any suggestions on this one?
    ===========================================================================
    ===========================================================================
    .


    SPA
    Saturday, December 05, 2009 10:07 PM
  • Create a new Folder in c:/ drive named as MyDB

    Open SQL Server Management Studio -> Right Click Databases -> New Database ->
    Give Database name as MyDB1 -> in the New Database window browse the path to c:/MyDB for both mdf and log files,
    so that both .mdf and .ldf files lie in c:/ drives MyDB Folder

    Right click the newly database created ->Tasks ->Import Data ->
    Choose Data Source as MyDB and Destination as MyDB1
    Basically IMPORT all your tables of MyDB into MyDB1

    So now you must be having a copy of your database MyDB as MyDB1 situated in c:/ drive MyDB folder

    Right Click the folder MyDB from path c:/MyDB

    Right Click -> Properties -> Security -> Edit ->Check Full Control for All Users
    Users like SYSTEM etc

    Use the connection string
    <add connectionString="Server=MYCOMPUTER\SQLExpress;Database=MyDB.mdf;Integrated Security=true" name="MYWEBSITE.My.MySettings.ConnString" providerName=".NET Framework Data Provider for SQL Server" />

    for which you got the error
    Error:
      Cannot open database "MyDB.mdf" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

    Now change the database=MyDB1



    write below line in new query window
    sp_grantlogin 'NT AUTHORITY\NETWORK SERVICE'
    run it under your database and also under master



    On MyDB1 in SQL Server Management Studio under Security tab do the following
    security -> Users -> Right Click->  New User
    Write User Name and Login Name both as NT AUTHORITY\NETWORK SERVICE
    Dont forget to check db_datareader and db_datawriter both in Owned Schemas and Database role membership windows ->OK


    Right Click the Server Name in SQL Server Management Studio the first topmost item in the Object Explorer
    My Server Name is YOUSUFKHAN-PC (SQL Server 10.0.2531 yousufkhan - PC\yousuf khan)
    Right Click-> Properties -> Connections

    Maximum number of concurrent connections (0=unlimited)
    so keep it zero

    Also there is option for Timeout 

    On my system i access the same database of sql server concurrently through a browser acessing the application hosted on IIS on my machine, through same application - same sql database - using Visual Studio ,
    and same sql database - through a query in Sql server management studio.

    But there is no point in accesing the same sql database through different aplication on same machine.

    There is point if you deploy an application using IIS having a SQL database on a server and 1000 people using the intranet are able to acess it concurrently.

    " Make everything as simple as possible, but not simpler."


    "A man can live a good life. Be honorable, give to charity…But in the end, the number of people who come to his funeral is generally dependent on the weather."




     

    Sunday, December 06, 2009 11:07 AM
  • yousufkhan THANK YOU SO VERY MUCH for such a detailed response.

    I will follow your steps and see what that will do, and return my findings.

    I am confused about your statement:  "...But there is no point in accesing the same sql database through different application on same machine..."

    When I debug and work with developping new features on the fly(database is connected to Web App in Visual Studio).
    I concurrently keep various query and design windows of the database to track data values and to adjust structure as
    needed.  (MSDE database engine of Vale Software let me do that at will) ...and I can see that you too mention
    that you do access from various apps.)

    By the way, The SQL Management Studio is the only tool that allows enough functionality to do that.
    (SQLServer Explorer in Visual Studio is pretty much useless).

    I am surviving now by constantly Restarting the SQL Server...
    .



    SPA
    Sunday, December 06, 2009 8:34 PM
  • tommy123456 's solution has solve my same problem :)
    Monday, January 04, 2010 8:32 AM
  • Tommy. That fixed my solution like a plum. Thanks mate!
    Thursday, February 04, 2010 9:50 AM
  • thanks a lot Sidheshwar ... ur suggestion worked for me :)
    Wednesday, February 24, 2010 7:16 PM
  •  Dear all ,

     I have same problem. i have tried every possiblity which is here but till not solve my problem. actualy my sql server 2000 install on diffrent machine and iis server is install on another machine. when run the page in iis machine page successfull connected to sql server no any error are occured but when i have access same page on any network machine or sql server install machine then give error "message Error in: http://dwetaedp/personnel/webpages/login.aspx. Error Message:System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'."

         Also i have seen above solution try every thing but till not work.

     

     

    my email id is hitu.girase@hotmail.com so pls. forword the solution on this email id.
    Wednesday, April 07, 2010 6:31 AM
  • This fixed my problem with this error...

    Open 'Security->Logins' in SQL2005 Management Studio, right click on 'NT AUTHORITY\NETWORK SERVICE' and click on 'properties'.

    Then click on 'User Mapping', and map the appropriate database, then click on tableN_FullAccess etc... for each table that access to which is required.

    Wednesday, September 29, 2010 10:59 AM
  • The answer provided by Terentula fixed my problem as well.  Thanks!
    Thursday, January 13, 2011 6:12 PM
  • Your instruction worked for me, thanks.
    ds
    Monday, August 08, 2011 4:11 AM
  • I don't know if this will help anyone, but I had this problem. The problem was due to the identity setting of the Application Pool that my service was using in IIS. If you set the appropriate identity there, you should be good. In my case, the default was set to NT Authority\Network Service.
    Tuesday, October 04, 2011 9:10 PM
  • THANK YOU VERY MUCH

    IT WORKS ON R2 ALSO

    Tuesday, December 20, 2011 9:20 AM
  • thanks a lot sir, was very much worried,, it worked like a breeze, thanks again
    Wednesday, April 25, 2012 7:10 AM
  • you saved my life :)!!
    Tuesday, October 09, 2012 2:10 PM
  • This is an old thread - and people are still hitting it.  I just installed SQL 2012 express and IIS7, and set the app pool of my application to NT AUTHORITY\NETWORK SERVICE.  And immediately ran into the trouble that is mentioned on this thread.  I want to summarize to help all of those who come after me - this was not a "one thing will do it" for my case.

    What did work (all of the changes happen in SQL server management studio)

    1.  In SQL server management studio, create a DB account for the windows credential 'NT AUTHORITY\NETWORK SERVICE'

    2. Then in your db for your app, set up a user account with the right permissions so that your new user account is known to your DB.  (this is not enough though).  I chose "db_reader" and "db_writer" for my web app that can read/write to DB, also granted "execute".

    3.  Open a sQL query window and type the following and then execute

    USE MASTER

    GO

    SP_GrantLogin 'NT AUTHORITY\NETWORK SERVICE'

    GO

    SP_GrantDbAccess 'NT AUTHORITY\NETWORK SERVICE'

    GO

    USE MYDBNAME <-- substitute your database name for "MYDBNAME" on this line, and omit everthing after the DB name

    GO

    SP_GrantLogin 'NT AUTHORITY\NETWORK SERVICE'

    GO

    SP_GrantDbAccess 'NT AUTHORITY\NETWORK SERVICE'

    GO

    Now - click the execute button (the red exclaimation point), and these commands will all run.

    After that, at least for me, my app was able to connect to the DB just fine.  My app is using .NET 4.5 and entity framework to access the DB - so if this helps you in the same circumstances, then good.

    Some comments on this long thread.  Many of the suggestions will open you up for problems security wise.  Particularly, don't run an app pool as NT AUTHORITY\LOCAL SYSTEM - this is the system administrator on your machine, and if you get hacked, it's an easy way to gain access and install all kinds of nasties.

    I can't say that I am in favor of the new IIS 7 app pool default identity - it is too much of a nobody if your app needs to access a full SQL server DB on another server.  This identity is great for MSFT because it doesn't translate to any credential or identity over a network - so that protects us from bad reputation etc.  But for apps that have to use the network to get to another service or a remote DB, it's a useless facade.  In these cases, always create a domain and a domain account for your app, and preferably a different domain account for each unique app so you can control access on a per app basis.

    Another, sometimes better option, is to turn on ASP.net impersonation in the application pool in IIS.  What this does is let an authenticated domain user have their own credentials passed through to calls made by the web page.  It's a bit harder to manage ACL's in the DB this way because you either have to create a group per app (or two or three depending on permission permutations) and then manage users in groups on a per called resource basis.

    Of the two, it's a preference or policy decision - but I personally like when I can go with a domain id from the app pool, and use IIS role based access to control which users (in which groups) get to which pages.  If they cannot run the page, they can't perform the functions on the page, so the delegation of identity through IIS is a lower cost way to manage the administration of complex security.

    Good luck all - may the NETWORK AUTHORITAY gremlins never bight you again (misspelling on purpose for humor)


    Microsoft Corporation

    Tuesday, December 11, 2012 6:16 PM
  • Thank  alot  tommy123456 ...your post helped me.....

    • Proposed as answer by SumitSRA Thursday, June 27, 2013 12:34 PM
    • Unproposed as answer by SumitSRA Thursday, June 27, 2013 12:34 PM
    Thursday, June 27, 2013 12:33 PM
  • I have a good solution for your 1st issue....

    Open Solution Explorer right click on u r project..........

    click on properties or simply click alt+enter tab from your application,click on 'Use Visual Studio Development Server' so it will work fine.

    • Proposed as answer by mnj00007 Thursday, August 01, 2013 6:02 PM
    Wednesday, July 10, 2013 6:47 AM
  • for this problem goto ur iis server and then goto "view application pool" after then goto "set application pool default" in this section you will find general,cpu,process model,process orphaning...and all..

    after that you need to select "process model" and goto identity part and then goto "built in account" and here you need to select "Local System" and then ok..

    this problem will definitely be solved...

    • Proposed as answer by mnj00007 Thursday, August 01, 2013 6:11 PM
    Thursday, August 01, 2013 6:10 PM