Monday, January 25, 2010

Login failed for user 'NT AUTHORITY\IUSR'

If you encountered this error while running your published website or web service in IIS7:

Message: Sys.WebForms.PageRequestManagerServerErrorException: Cannot open database "[DB_NAME]" requested by the login. The login failed.

Just follow these simple steps to solve the problem.

1. Open SQL Server Management Studio.



2. On the left menu, expand Security then Logins. Check if 'NT AUTHORITY\IUSR' exists. If not then that is the cause of the problem.




3. Right-click on Logins then click New Login...



4. On the General page, click Search...



5. On the next popup window, click Advanced...



6. Then on the following window, click Find Now and find IUSR on the Search Results. Then click OK.



7. Back on the left menu, you'll now see the 'NT AUTHORITY\IUSR' user. Right click on it and click Properties.




8. On the Server Roles page, check on sysadmin.



9. Then on the User Mapping page check on the database name you need access to; and below that on the database role membership make sure to also check on db_owner then click OK.






...And that's a wrap, you shouldn't be seeing the login failed error now.



-k

39 comments:

  1. Thanks for the article this really helped me out.

    ReplyDelete
  2. great article...

    u solve my problem juz now...

    thanks :)

    ReplyDelete
  3. Thanks for the article..

    it helped me alot..

    ReplyDelete
  4. thank you so much
    it solved my problem.......
    it helped me after lot of frustuation

    ReplyDelete
  5. I have NT AUTHORITY\IUSR as part of the allowable login users to my SQL but still getting the same error

    ReplyDelete
  6. Thanks a lot, after several hours of playing around, just what I needed!

    ReplyDelete
  7. A wonderful , Clear and working solution to my frustrating problem.

    ReplyDelete
  8. thank you very very much you help me in this topic

    ReplyDelete
  9. REALLY THAAAAAAAANKS FOR THISSSSS

    ReplyDelete
  10. I have to disagree with this solution, my understanging is this solution grants any anonymous users access to the database which is really bad.

    ReplyDelete
  11. Hi guys, I am trying to follow the instructions but I cannot see 'NT AUTHORITY\IUSR' in the list of my SQL users. How can I add this user? Anything should be set in IIS?
    Thanks,
    V

    ReplyDelete
  12. Thanks a lot, I was so confused having this problem, well done.

    ReplyDelete
  13. Great Article!! Thanks for it!! Just solved my problem in a minute...

    ReplyDelete
  14. Very Thanks Honey :xXx it solved my problem....

    ReplyDelete
  15. thanks a lot, awesome article!!

    ReplyDelete
  16. Thank you so much! This solved my problem :-)

    ReplyDelete
  17. Awesome! It worked!

    ReplyDelete
  18. Much appreciated that you took the time to post this how-to

    ReplyDelete
  19. good work, thanks

    ReplyDelete
  20. Thank you!!! :)
    Very VERY helpful!

    ReplyDelete
  21. Problem SOLVED!!!

    Thanks to you

    ReplyDelete
  22. yahhhhhhhhhhhh

    ReplyDelete
  23. I am having this error(below):
    Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

    Adding the 'NT AUTHORITY\ANONYMOUS LOGON' the problem goes away...but I am concern about giving database ownership to NT AUTHORITY\ANONYMOUS LOGON.

    Should I be concerned? THanks

    ReplyDelete
  24. oh my god... I am concern about giving database ownership to NT AUTHORITY\ANONYMOUS LOGON.

    ReplyDelete
  25. very much appreciated!!

    i really prefer tutorials with pictures. very helpful man. thanks

    ReplyDelete
  26. Please don't do this. Granting DBO access to IUSR* is a very bad idea. You want to grant the least rights possible to users. If, after granting public access to a user you still see errors you should be granting access to the stored procedures you are using to public, not just giving users the ability to create or drop any table they like.

    ReplyDelete
  27. I hope you are joking... this is a suicide

    ReplyDelete
  28. What an amazingly bad idea. Granting sysadmin privileges on the server to IUSR or ANONYMOUS LOGON is setting your machine up to get rooted easily. Assign permissions on an as needed basis, granting the absolute minimum required to any given database user.

    ReplyDelete
  29. This article, combined with the "Thank you so much!!!" comments makes this the FUNNIEST. POST. EVER.

    ReplyDelete
  30. I'm printing this out and hanging it on my wall of "Worst Advice In The History Of The World". The author of this post is truly without a clue.

    ReplyDelete
  31. Please folks do NOT follow this advice. This is the SQL Security equivalent to enabling the Guest account in windows.

    Instead the account needed to access should have very minimal rights and only to those objects required. For example, if the account needs to only perform SELECTs and only a few tables, please put the rights specifically there. If there are plenty of tables, create a role and assign permissions that way. Worse case add the user to the data readers.

    ReplyDelete
  32. Bah..Bah...Bah..
    Lots of stupid sheep out there.
    If you don't know what you are doing maybe you should find another profession.

    ReplyDelete
  33. You r the man :)
    Thank a lot Prof.

    ReplyDelete
  34. thanks
    http://www.hoclaptrinhweb.com

    ReplyDelete