Login failed for user 'IIS APPPOOL\ASP.NET v4.0'

后端 未结 30 4722
天命终不由人
天命终不由人 2020-11-22 15:52

I have a web project (C# Asp.Net, EF 4, MS SQL 2008 and IIS 7) and I need to migrate it to IIS 7 locally (at the moment works fine with CASSINI).

Locally in IIS I ha

相关标签:
30条回答
  • 2020-11-22 16:08

    As pointed out, Do not use Windows Authentication, Use SQL Server Authentication

    Also if you created connection using "Server Connection" dialog, make sure to check the connections in web.config. It is likely that you created/modified connection and it was stored as trusted connection in web.config. Simply use this authentication

    <add name="MyDBConnectionString" connectionString="Data Source=localhost;Initial Catalog=Finantial;User ID=xxx;Password=xxx" providerName="System.Data.SqlClient"/>
    

    which should fix the error.

    0 讨论(0)
  • 2020-11-22 16:08

    I did exactly as @JeffOgata said but I got the error:

    Windows NT user or group 'IIS APPPOOL\ASP.NET v4.0' not found. Check the name again. (Microsoft SQL Server, Error: 15401)
    

    I looked at my error message again and it said Login failed for user 'IIS APPPOOL\DefaultAppPool'.

    After adding a user named IIS APPPOOL\DefaultAppPool everything worked.

    0 讨论(0)
  • 2020-11-22 16:09

    I Have the same problem I solved it by changing Integrated Security=True to false now its working

    0 讨论(0)
  • 2020-11-22 16:10

    For the record, if you encounter this error after switching from LocalDB to SQLEXPRESS, make sure the database already esists in SQLEXPRESS. You can verify this in Management Studio.

    I had the same problem when using Entity Framework after switching to SQLEXPRESS from LocalDB. I had to run Update-Database command. I was able to successfully connect after that.

    0 讨论(0)
  • 2020-11-22 16:11

    I had this message and I use Windows Authentication on the web server.

    I wanted the currently authenticated web user to be authenticated against the database, rather than using the IIS APPPOOL\ASP.NET v4 User specified in the App Pool.

    I found by entering the following in the web.config fixed this for me:

    <system.web>
      <identity impersonate="true" />
    </system.web>
    

    https://msdn.microsoft.com/en-us/library/bsz5788z.aspx

    I see other Answers regarding creating the AppPool username in the SQL DB or just to use SQL Auth. Both would be correct if you didn't want to capture or secure individual Windows users inside SQL.

    Tom

    0 讨论(0)
  • 2020-11-22 16:12

    You can change the ApplicationPoolIdentity from IIS7 -> Application Pools -> Advanced Settings. AdvancedSettings

    Under ApplicationPoolIdentity you will find local system. This will make your application run under NT AUTHORITY\SYSTEM, which is an existing login for the database by default.

    Edit: Before applying this suggestion you should note and understand the security implications.

    0 讨论(0)
提交回复
热议问题