Login failed for user 'IIS APPPOOLASP.NET v4.0'

Looks like it's failing trying to open a connection to SQL Server.

You need to add a login to SQL Server for IIS APPPOOLASP.NET v4.0 and grant permissions to the database.

In SSMS, under the server, expand Security, then right click Logins and select "New Login...".

In the New Login dialog, enter the app pool as the login name and click "OK".

Login failed for user 'IIS APPPOOLASP.NET v4.0'

Login failed for user IIS APPPOOLDefaultAppPool

Thanks jobran456 for reply, but this thread suggests not to use NetworkService in IIS 7+ due to security considerations. Instead it is recommended to use ApplicationPoolIdentity as default Identity setting. This is by default in IIS 7 and later but you need also check for the followings (summarized from this thread):

  • Set Read permission for IIS_IUSRS on the the web application's local directory. IIS_IUSRS is used when Anonymous Authentication is enabled.
  • Create a new SQL Login (user) as "IIS APPPOOLDefaultAppPool" and give it db_owner role membership.
  • it's not a real windows account, you can't user the "Search" button.  Just enter the account name 'IIS APPPOOLDefaultAppPool', set your security settings, and click OK.
原文地址:https://www.cnblogs.com/itelite/p/4282566.html