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‘.
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.
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.
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.
Step 3:
Then Select UserMapping in the left pane. It will open the Databases that you have in that instance.
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/
Harish said
wow!!! the problem is solved in such a simple fashion..I do really appreciate u r effort in making this!!
soujanya s said
Thanks for ur help in such an easy way…
Nida said
Hi,thanks for the help..
Arif said
DNR,
You rule….Thanks for such nice steps for actual problem.
Thanks,
Arif
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
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?
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’
Ryu said
BulzEye
Ahmedkiwi said
Thaaaaaaaaaaaaaanks aloooooooot
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!!!!!
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.
uzi blum said
man you are a the best!
it is like a magic!
S. Darya said
Thank you very much. Worked like a charm!
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
Waqas said
Thank you buddy, problem solve…
Pat said
Wow – spent 3 hours on this and finally I’ve found this post — excellent; works as expected!! Thank you very much!
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
Sam said
Thank you Sir
Asghar said
These steps solved my problems
Thank you so much
KBS said
Very informative and descriptive
enviro said
This was right on and so useful! Thank you for the great directions. I appreciate it!
Dennis said
you are a diamond! thanks alotttt!
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!!!
soujanya s said
thanks a lot..it’s working
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
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?
DotnetRuler said
Thats interesting !! 😦 Do you have admin access to create a login ??
hanhnguyen said
I run SQL Server Management Studio as Administrator but I didn’t see node “NT AUTHORITY/NETWORK SERVICE”. What’s wrong here?
Nasir said
Hi
Excellent instructions, worked like a charm. Thanks for the help. Will be checking back here for more stuff
Nas
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
dodo said
You’re Great..
I really thank you..
Sagar said
really gr8 post..!!!
you ROCK..
prabhu said
Superb Example, well done!
Albert Jann said
And last thing many forgot… replace:
connectionString=”Data Source=.\sqlexpress;
with:
connectionString=”Data Source=(local);
DotnetRuler said
Thanks Albert..
Blog J.Schweiss | Troubleshooting HTTP-500 Errors said
[…] 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 […]
SHANKAR REDDY said
Thank you very much………It’s working
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.
Network Load Balancing – Same Server Two Sites - Admins Goodies said
[…] 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 […]
innomin said
One of the best tutorials I have read! Thanks
Naveed said
this is grate saved my time
Louise Ege said
Thank you very much for this, it really saved me a LOT of time 🙂
İnternetten Anket Doldurarak Para Kazan said
Thank you very much for this, it really saved me a LOT of time 🙂 One of the best tutorials I have read! Thanks
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!
chalskribo said
thank you for the solution
Godesteo said
Thanks a lot!!!
eder said
Thanks a lot!!!!!!!!!!!!! Gracias!!!!!!
Musya said
It’s grate post and for me was very helpful!!! Thanks a lot! =)
rajaraok9 said
BELIEVE ME THE ABOVE ONE WILL NOT WORK IF YOU ARE NOT SETTING IN IIS NETWORK SERVICES UNDER APPLICATION POOLS
rajaraok9 said
HELLO PROGRAMMERS THE ABOVE ONE WILL NOT WORK IF YOU ARE NOT ENABLING NETWORK SERVICES IN IIS UNDER APP POOLS
Rahul said
@rajaraok9 Dude thanx a lot … you made my day.. cheers 🙂
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.
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
upul said
I wasted much more time for this, Thank you very very much
aladin said
great post. thanks a lot
Sanjay said
Thanks.. Issue resolved
Login failed for user ‘IIS APPPOOLDefaultAppPool’ | dorothyDorothy's Blog said
[…] 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/ […]
Md.Jahurul Islam said
Good very nice.
sankalp sawant said
awesome…useful alot
HEMANTH said
GREAT ITS WORKING FOR ME THANKS A LOT
Shubham Pandey said
You are freaking awesome man…Thanks a lot
Login failed for user ‘IIS APPPOOL…’ | Dawei's space said
[…] https://devilswork.wordpress.com/2009/01/28/login-failed-for-user-networkservice/ […]
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 .
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.
shreyas said
Thank you very much…really it was too helpfull for me…
shruti said
Thanks a lot.
bismetro@live.com said
Great !…..Thanks a lot -*M.R.Sriram,India
Rahul Jain said
Amazing Solution, Thank you very much
Bhavin Goradiya said
Thanks Buddy. I got the solution. It was a great help.
biswa said
excellent works for me aswell.You are awsome
Laercio Estrada said
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!
login failed for user said
[…] Login Failed For user NetWorkService « Devils Work […]
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.
Wai Hnin said
I tried already upon your suggestion. However, it still have the same error.
Michael Rozenberg said
Hey, This worked like a charm! Thanks very much.
rannel said
I already done the steps but still it didn’t worked … 😦 help
Vivek Singh said
Thx… a lot
Pash said
Thank you for this post….
Roscillin said
Thanks so much for your help! It worked