locked
website login was working--now getting "Login failed" message. RRS feed

  • Question

  • User1009096385 posted

    I am inexperienced with SQL Server but have managed to create and use a SQL Server 2005 Express database in my new data-intensive website.  I've been debugging the website for weeks and am just putting on the finishing touches and doing one more round of debugging.  I downloaded SQL Server 2005 Express Management Studio to the web server so I could make a small adjustment to one of the views in the database.  I also copied a few pages I had modified in development onto the server.  Since then I have not been able to log in to the website.  The error message I am getting is "cannot open database "AspMembership" requested by the login.  The login failed.  Login failed for user 'NT AUTHORITY\NETWORK SERVICE'."  "AspMembership" is the name of the database as it shows up in Management Studio, so I have tried detaching the database in Management Studio.  Also, since the web.config file was one of the files I had altered, I have restored the original web.config file which had been working before.  I have also tried everything else I can think of, but nothing seems to work.  And web searches are not helping.  Can someone give me a clearer idea of what might be wrong?

    Wednesday, April 6, 2016 7:25 PM

Answers

All replies

  • User-286291038 posted

    Hi LouAtMonaco,

    I think your website worker process is running in the Network Service account. Please try providing this account access to your AspMembership database.

    Please refer to the below resolved thread,

    http://forums.asp.net/t/1221631.aspx?how+to+grant+Network+Service+or+ASPNET+user+accounts+permissions+to+connect+to+database

    The below threads also has more information,

    http://stackoverflow.com/questions/2251839/login-failed-for-user-nt-authority-network-service

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 6, 2016 7:37 PM
  • User1009096385 posted

    Thanks, I will try that.  But so I understand what is going on, can you tell me why I would need to do this when the login was working before?  Could opening the database in Management Studio have changed something about the permissions?

    Wednesday, April 6, 2016 8:55 PM
  • User1009096385 posted

    I tried to add the "NETWORK SERVICE" account as directed in your second link, however it was not one of the choices.  I can add [BUILTIN\Administrators], [BUILTIN\Users], [NT AUTHORITY\SYSTEM], [sa], or [<server name>\SQLServer2005MSSQLUser$<server name>$SQLEXPRESS]

    Wednesday, April 6, 2016 9:34 PM
  • User-219423983 posted

    Hi LouAtMonaco,

    First of all, you should make sure your connection string right connects to the SQL Server, especially the server name.

    Then, if there’s no 'NT AUTHORITY\NETWORK SERVICE' in the user list, you could follow below steps to add it and then grant the right permissions as suggested by Jed in the above second thread.

    1.Login to SqlExpress via SQL Server Management Studio

    2.Go to the "Security" directory of the database

    3.Right-click the Users directory

    4.Select "New User..."

    5.Add 'NT AUTHORITY\NETWORK SERVICE' as a new user

    6.In the Data Role Membership area, select db_owner

    7.Click OK

    Best Regards,

    Weibo Zhang

    Thursday, April 7, 2016 1:35 AM
  • User364663285 posted

    Try to put this

    	<connectionStrings>
    		<add name="conn2" connectionString="Data Source=192.168.?.?\your_db_instance;Initial Catalog=your_db_schema;Integrated Security=False;User ID=your_db_login;Password=??????" providerName="System.Data.SqlClient"/>
    	</connectionStrings>
    



    within Web.config/app.config file in your project, to ensure the project will work fine with the database.

    Thursday, April 7, 2016 2:23 AM
  • User1009096385 posted

    Connection string in web.config file is not the problem.  Login has been working for weeks with no problems.

    The login was working fine until I opened the database in Management Studio and now the login doesn't work. 

    Cannot add user [NT Authority\Network Service] in Management Studio because that user does not exist.  I cannot create a user in management studio--I can only add users that already exist.

    Thursday, April 7, 2016 6:43 PM
  • User-219423983 posted

    Hi LouAtMonaco,

    Connection string in web.config file is not the problem.  Login has been working for weeks with no problems.

    The login was working fine until I opened the database in Management Studio and now the login doesn't work. 

    Cannot add user [NT Authority\Network Service] in Management Studio because that user does not exist.  I cannot create a user in management studio--I can only add users that already exist.

    According to the account name “NT AUTHORITY\NETWORK SERVICE” you could know that a service that runs in the context of the NetworkService account presents the computer's credentials to remote servers.

    As you couldn’t add the account in your database, I suggest you’d better try using the above connection string that specifies the login name and password suggested by wmec, not using windows authentication.

    Best Regards,

    Weibo Zhang

    Friday, April 8, 2016 5:09 AM
  • User1009096385 posted

    I was able to resolve the problem.  In Management Studio, I had to first open the Security node for the general database and there I was able to add NT_AUTHORITY/NETWORK SERVICE as a user, then when I opened the Security node for my specific database, I was able to add NETWORK SERVICE as a user and set the specific roles I needed it to have for the website to use the database.  It was this two-step process that I did not understand.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 21, 2016 10:03 PM