0

I just deployed my first .NET Core web application. Everything was fine on a development environment with VS 2019 and IIS express but when I run the application on a production server (WIN2012) I got this error:

Application started. Press Ctrl+C to shut down. fail Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HLTB3NQ3M57Q", Request id "0HLTB3NQ3M57Q:00000001": An unhandled exception was thrown by the application. System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Accesso non riuscito per l'utente 'XXX\SRV-XXX01$'.

where 'Accesso non riuscito per l'utente' is the Italian of 'Login failed' and XXX\SRV-01$ is the user attempting the login, made up of XXX is the domain name and SRV-01$ is the user name that is equal to the server name plus $.

Now the problem is that this user XXX\SRV-01$ is not defined anywhere in my project. It is not the user I have in my connection string. I tried to change the connection string but it looks like has no effect on this error.

Suraj Kumar
  • 5,547
  • 8
  • 20
  • 42
Efrael
  • 557
  • 1
  • 4
  • 11
  • 2
    You'll find a lot of duplicate questions. `XXX\SRV-XXX01$` is the computer's account. When you try to connect to a remote database server with Windows authentication, the connection is made using the current *domain* user's account. If the application runs under a local account, the computer's account is used for remote access, because the local account simply doesn't exist on the remote server. For web apps, the "current user" is the application pool's account. The default app pool account is a local account – Panagiotis Kanavos Feb 06 '20 at 16:36
  • 1
    The real solution is to create a domain account for the application pools and add it to the SQL Server database. The hack would be to add the computer account to SQL Server *but* that would allow *any* application running on that server to connect to the database – Panagiotis Kanavos Feb 06 '20 at 16:37
  • Thank you for the prompt answer! I understand the point but this also happens if I change the connection string forcing to use an existing sql account (like sa). If I got you is the application pool that drivers the connection, is it right? So what the connection strings is used for? – Efrael Feb 06 '20 at 16:42
  • I also tried to add the XXX\SRV-XXX01$ user to sql users but still not works (even if I know this should not be the solution) – Efrael Feb 06 '20 at 16:43
  • Kerberos double-hop problem? https://stackoverflow.com/questions/14928350/how-can-i-fix-the-kerberos-double-hop-issue – HardCode Feb 06 '20 at 18:18
  • I finally solved managing user and permissions on db thanks to @PanagiotisKanavos – Efrael Feb 06 '20 at 19:23

0 Answers0