This was the error I got while trying to directly connect to a SQL Server database, from within a SharePoint web part, using the option, Windows Authentication.
Login failed for user ‘NT Authority\IUSR’
The solution is to allow login for IUSR. Here are the steps to do it: –
1) Open Microsoft SQL Server Management Studio.
2) Under Security, right click the Logins leaf and select New Login.
3) In the Login Name, type in IUSR and hit the Search button.
4) This will open up a new window. Here also, type in IUSR in the object name and then, click on Check Names. Once, it has searched the name, click OK to close the window.
5) By default, you’ll be shown the name in the format, [machineName]\IUSR. For example, in the following case, SERVERPIYUSH is my [machineName].
6) Change the [machineName] to NT Authority. So now, the Login name will look like this, NT Authority\IUSR
7) Now, select Server Roles from the top-left navigation pane and assign the role, sysadmin. Now, this totally depends upon your requirement. In my case, I needed this permission. If you don’t need the highest privilege then go for the ones that serve your purpose. By default, the role, public will be applied to it.
8) Hit the OK button.
After allowing access to IUSR, I was now able to successfully connect to my SQL Server database using Windows Authentication through my code.
- NT Authority, refers to the OS itself. It means that the OS will authorize some stuffs on your behalf.
- Similarly, IUSR is nothing but a legacy account for allowing anonymous access. So, in totality, we can say, that NT Authority\IUSR means that OS will grant anonymous access on my behalf with the roles I have explicitly specified for it.
One thought on “Login failed for user ‘NT Authority\IUSR’”
Thanks dude. 🙂 That error was driving me nuts. Now I can get on and develop some code. Best wishes, Lenz.