Devils Work

—Blog By DotNetRuler

  • Categories

  • Archives

Login Failed For user NetWorkService

Posted by DotnetRuler on January 28, 2009


Hi Friends(Dev’s),

I have been following the Asp.Net Forums from the past one month, and got to know people asking this issue more and more. So i finally decided to put this in my blog along with screen shots for easy understanding purpose.

Problem:  Login failed for user ‘NT AUTHORITYNETWORK SERVICE

Exception Details: System.Data.SqlClient.SqlException: Cannot open database “my_db” requested by the login. The login failed. Login failed for user ‘NT AUTHORITYNETWORK SERVICE.

problem2 

Solution:

The reason why you are seeing this screen is .. When browser requests a page, request goes the IIS (Internet  Information Services). If  the request needs some data from the SQL server IIS tries to access the SQL server With this Access name which dont have credentials to access that particular database. To Resolve this you have to give the permissions for the user to that particular database as follows.

Step1:

Open SQL Server Management Studio and in the left pane below Databases you will see Security. Under Security Section you will see Login. in the subnodes for Login you can see NetworkService User.

step1

What If you dont See that user ?

You need to Right Click on the Login and then Go to NewLogin ==> you will see the below Screen. Click on the Search Button Which will opens another Window.  Click Advanced Button, Which populated another Window called as “Select User Group“. If you click on the “Find Now” it will show all the users available in the Search Results Section. There You will Find the User Network Service. Select it and Clcik ok.

 newlogin1

newlogin2

newlogin4

newlogin5

newlogin6

Step 2:

Once you see the user in the Login Subnodes Right Click on the particular User and go to the Properties. You will see the below Screen.

step3

step4

Step 3:

Then Select UserMapping in the left pane. It will open the Databases that you have in that instance.

step5

Step4:

Check the Database for which you want to give the permissions, in the lower pane you will some roles for that User for that Particular DataBase.  If you check db_owner role for that particular user then you are done.. 🙂

All Comments are appreciated So that i can post my next post t better than this..

Thanks

DotnetRuler

Keep Rocking..\m/

79 Responses to “Login Failed For user NetWorkService”

  1. Harish said

    wow!!! the problem is solved in such a simple fashion..I do really appreciate u r effort in making this!!

  2. Nida said

    Hi,thanks for the help..

  3. Arif said

    DNR,

    You rule….Thanks for such nice steps for actual problem.

    Thanks,
    Arif

  4. raj said

    Hi,

    i am new to web service.can u pls give any sample for webservice that is connect to sql..then steps to deploy webservice

  5. J_Quest said

    I really appreciate the effort you put into your post, and that you replied to my problem. It did not work. I saw the user as described, did exactly as described, restarted SQL server and still cannot login using my connection string. Is it possible to troubleshoot it with me?

  6. Ravi said

    I have developed a few reports on SQL Server 2008+VS 2008 and deployed them to the SSRS built in reporting URL (http://servername/reports)

    During the report creation I have used SQL authentication for the DataSourse and provided them with ‘Sa’ and pwd ‘xyz’.

    Now I start with a dummy user giving him access to the site and to a couple of folders and reports inside them.

    My Question are:

    Without any prompt screen for userid and password he can view the URL and see the folders.Can I have a prompt screen?

    When he opens the folder and tries to view the report always hits a hardstop error

    An error occurred during report processing
    Cannot connect to the DataSource ‘XYZ’
    Login failed for the user ‘xyz’

  7. Ryu said

    BulzEye

  8. Ahmedkiwi said

    Thaaaaaaaaaaaaaanks aloooooooot

  9. Gibbon said

    Still doesn’t work, what else could it be?!

    Error message states the xxxxx\ASPNET user doesn’t have access but I HAVE granted FULL access!!!!!

  10. jack said

    If you do that, your not authenticating the user you are just allowing the iis service to connect if you look at the user identity, it will still be network service not “bob” from accounting.

  11. uzi blum said

    man you are a the best!
    it is like a magic!

  12. S. Darya said

    Thank you very much. Worked like a charm!

  13. Steve F said

    Dear DotnetRuler,

    I appreciate your thorough answer, however, this does not resolve my basic issue. In our environment, we need the database server to know the actual user accessing the database. Our DBA will not allow access in a manner that could be pretty much anyone on the database.

    We have Integrated Windows Authentication, Impersonation=true, trusted_connection=yes, etc. We even have all our databases running Kerberos to manage the authentication across machines in the domain. We have many ASP sites that all work just fine authentincating on the database server as the end user.

    ASP.NET is not behaving properly and won’t authenticate through to the database server. So, can you suggest a solution that does not involve using a fake user to authenticate on the database?

    Thank you kindly,
    Steve F

  14. Waqas said

    Thank you buddy, problem solve…

  15. Pat said

    Wow – spent 3 hours on this and finally I’ve found this post — excellent; works as expected!! Thank you very much!

  16. Steve F said

    Dear DotnetRuler,

    I appreciate your thorough answer, however, this does not resolve my basic issue. In our environment, we need the database server to know the actual user accessing the database. Our DBA will not allow access in a manner that could be pretty much anyone on the database.

    We have Integrated Windows Authentication, Impersonation=true, trusted_connection=yes, etc. We even have all our databases running Kerberos to manage the authentication across machines in the domain. We have many ASP sites that all work just fine authentincating on the database server as the end user.

    ASP.NET is not behaving properly and won’t authenticate through to the database server. So, can you suggest a solution that does not involve using a fake user to authenticate on the database?

    Thank you kindly,
    Steve F

  17. Sam said

    Thank you Sir

  18. Asghar said

    These steps solved my problems
    Thank you so much

  19. KBS said

    Very informative and descriptive

  20. enviro said

    This was right on and so useful! Thank you for the great directions. I appreciate it!

  21. Dennis said

    you are a diamond! thanks alotttt!

  22. Aisha said

    Fantatstic!!! You’re the best!! Unassuming (of ones knowledge level) and simplyfing it all for the new beginners to follow…..WONDERFUL thank you!!!

  23. soujanya s said

    thanks a lot..it’s working

  24. soujanya s said

    I am not able to send emails from my application..I checked smtp server in iis which is running fine. But i am getting the error..sending failure…Pls help

  25. Nathan said

    Two things:

    Back in step 1, what if “NT AUTHORITY/NETWORK SERVICE” doesn’t exist as a subnode under Logins?

    Also, I’ve attempted to add this login several times as described in this post, however each time Management Studio produces an error box with the following text:

    “Create failed for Login ‘NT AUTHORITY/NETWORK SERVICE’. (Microsoft.SqlServer.Smo) Additional Information: An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo) The server principal ‘NT AUTHORITY/NETWORK SERVICE’ already exists. (Microsoft SQL Server, Error: 15025)”

    This message seems to contradict the first point (that NT AUTHORITY/NETWORK SERVICE doesn’t show up as a subnode under Logins).

    Any ideas what’s going on?

  26. Nasir said

    Hi

    Excellent instructions, worked like a charm. Thanks for the help. Will be checking back here for more stuff

    Nas

  27. Vikas said

    Hi

    this is very useful for me,because when i am using WCF service with SQL Server 2008,but i continuously getting error,
    from 2 day ago, but your article has resolved my problem…..

    thanks dud

  28. dodo said

    You’re Great..
    I really thank you..

  29. Sagar said

    really gr8 post..!!!
    you ROCK..

  30. prabhu said

    Superb Example, well done!

  31. Albert Jann said

    And last thing many forgot… replace:

    connectionString=”Data Source=.\sqlexpress;

    with:

    connectionString=”Data Source=(local);

  32. […] https://devilswork.wordpress.com/2009/01/28/login-failed-for-user-networkservice/ Tags: Categories: Actions: E-mail | Kick it! | Permalink | Kommentare (0) | Comment RSS Ähnliche BeiträgeUnified .NET Framework Troubleshooting Guide.Net Trouble Shooting GuideRazorASP.NET Razor syntax is a simple programming syntax that lets you embed server-based code into a Web…Webmatrix und IIS7 – Verwirrspiele à la Microsoft?Endlich: die Lösung: http://www.caspx.net/WebMatrix/01/6613220101225135910525.html http://learn… Über den Author.Net, Silverlight & more Search TagsSQLServer SP2 Windows Firewall Archiv2011April (67)März (92)Februar (42)Januar (34)2010Dezember (13) Seiten-ÜbersichtBeispiel SeiteSeite 1 Blogroll Al NyveldtSudokuKids gets an upda…SudokuKids+ update is l…To update or not to upd… Download OPML file RecentPostsIIS – Database ManagerWPF CommandingPhysics engineASP.NET MVC3 Tools UpdateTroubleshooting HTTP-500 ErrorsSharepoint – Development setupSQLServer – connection stringsMVC Intranet ApplicationSQLExpress – the underlying provider failed to openLogParser […]

  33. SHANKAR REDDY said

    Thank you very much………It’s working

  34. Nagesh said

    if place my dbserver in one system, and application in other if i make NTAUTHORITY|NETWORK SYSTEM as dbo then how should i access from other server. imean i fi put application server in other system. instead of making dbo as systemowner we are making network service as DBO. is that correct.please reply to my mail if possible.

  35. […] following this I had a hunt around to find this article. It describes issues around the use of the SQLServer option in sessionState in your web.config. It […]

  36. innomin said

    One of the best tutorials I have read! Thanks

  37. Naveed said

    this is grate saved my time

  38. Louise Ege said

    Thank you very much for this, it really saved me a LOT of time 🙂

  39. Thank you very much for this, it really saved me a LOT of time 🙂 One of the best tutorials I have read! Thanks

  40. Sudipto Kumar Mukherjee said

    I followed the steps but it did not work. I then realized that instead of working with NETWORK SERVICES I must have worked with BUILTIN\Users. I did the user mapping for BUILTIN\Users and it worked like a charm!

  41. chalskribo said

    thank you for the solution

  42. Godesteo said

    Thanks a lot!!!

  43. eder said

    Thanks a lot!!!!!!!!!!!!! Gracias!!!!!!

  44. Musya said

    It’s grate post and for me was very helpful!!! Thanks a lot! =)

  45. rajaraok9 said

    BELIEVE ME THE ABOVE ONE WILL NOT WORK IF YOU ARE NOT SETTING IN IIS NETWORK SERVICES UNDER APPLICATION POOLS

  46. rajaraok9 said

    HELLO PROGRAMMERS THE ABOVE ONE WILL NOT WORK IF YOU ARE NOT ENABLING NETWORK SERVICES IN IIS UNDER APP POOLS

  47. M.Munirathinam said

    hai i have given error message in Asp dot net application, please refer my problem…….

    Server Error in ‘/empProject1’ Application.
    ——————————————————————————–

    Login failed for user ‘IIS APPPOOL\DefaultAppPool’.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Login failed for user ‘IIS APPPOOL\DefaultAppPool’.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

  48. Renata said

    After days of experimenting and wasting time, the frustration ended with your post. Thank You So Much. Clear & Concise.
    Best regards from Macedonia

  49. upul said

    I wasted much more time for this, Thank you very very much

  50. aladin said

    great post. thanks a lot

  51. Sanjay said

    Thanks.. Issue resolved

  52. […] In case you are having MSSQLServer issues here is a link on how to set the the permissions to allow the Network Service have access to your database: https://devilswork.wordpress.com/2009/01/28/login-failed-for-user-networkservice/ […]

  53. Good very nice.

  54. sankalp sawant said

    awesome…useful alot

  55. HEMANTH said

    GREAT ITS WORKING FOR ME THANKS A LOT

  56. Shubham Pandey said

    You are freaking awesome man…Thanks a lot

  57. […] https://devilswork.wordpress.com/2009/01/28/login-failed-for-user-networkservice/ […]

  58. Cleta said

    Hi my family member! I wish to say that this post is
    amazing, great written and include approximately all vital infos.

    I would like to look extra posts like this .

  59. Umesh Bhavsar said

    The above settings are perfect.
    However, if you still face an issue for ‘IIS APPPOOL\\DefaultAppPool’, you may want to check your IIS version.
    If you are using IIS 7.5, you will have to change the Identity setting which is by default ApplicationPoolIdentity to Network Service.
    This change will solve the problem.

    Hope it helps.

  60. shreyas said

    Thank you very much…really it was too helpfull for me…

  61. shruti said

    Thanks a lot.

  62. bismetro@live.com said

    Great !…..Thanks a lot -*M.R.Sriram,India

  63. Rahul Jain said

    Amazing Solution, Thank you very much

  64. Bhavin Goradiya said

    Thanks Buddy. I got the solution. It was a great help.

  65. biswa said

    excellent works for me aswell.You are awsome

  66. He leído tus artículos un par de veces queriendo encontrar algo diferente
    y la realidad es que así pasa. Cada que leo tus artículos encuentro algo nuevo.
    Te juro que llevo no menos de 3 horas leyendo cada una de las cosas que has escrito y me semejan geniales.
    Espero que no creas que intento acosarte jeje.
    Esta vez en serio, deseo decirte que es una agradable experiencia poder encontrarme con gente que
    tiene grandes habilidades con las letras. Espero que sigas así y que si
    se da el instante, podamos conocernos. Saludos!

  67. […] Login Failed For user NetWorkService « Devils Work […]

  68. Ram said

    Welldone boss.I broke my head for past 2 hours.After tried your suggestion only i can resolve this error.Kudos to you.

  69. Wai Hnin said

    I tried already upon your suggestion. However, it still have the same error.

  70. Michael Rozenberg said

    Hey, This worked like a charm! Thanks very much.

  71. rannel said

    I already done the steps but still it didn’t worked … 😦 help

  72. Vivek Singh said

    Thx… a lot

  73. Pash said

    Thank you for this post….

  74. Roscillin said

    Thanks so much for your help! It worked

Leave a reply to innomin Cancel reply