0

I've connected a SQL Server to an ASP .Net Core app, but now, everytime I launch the app, or call "Update-Database", in Visual Studio, returns the error

Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.

Also, I'm trying to deploy the app to an IIS Site, and when I browse it, the Server Manager log shows a bunch of errors, which expection is always ...

An unhandled exception has occurred while executing the request.

Exception: Microsoft.Data.SqlClient.SqlException (0x80131904): Login failed for user ...

... indicating an user that has no access to the SQL Server.

aRip
  • 23
  • 1
  • 2
  • 7
  • 1
    "The login is from an untrusted domain" Are you sure of your login ? – GaspardF Jan 16 '20 at 10:52
  • 1
    Sounds like your app's connection string is using Trusted Authentication, which won't work because the IIS_IUSR account won't be recognized by SQL Server. – AlwaysLearning Jan 16 '20 at 10:57
  • 1
    Possible duplicate https://stackoverflow.com/questions/22415319/system-data-sqlclient-sqlexception-login-failed-for-user – Wesley Nightingale Jan 16 '20 at 11:09
  • 2
    Does this answer your question? [System.Data.SqlClient.SqlException: Login failed for user](https://stackoverflow.com/questions/22415319/system-data-sqlclient-sqlexception-login-failed-for-user) – Wesley Nightingale Jan 16 '20 at 11:10
  • So do I have to enable Windows Authentication in both ASP.NET Core and SQL Server? Because the app has Anonymous Authentication enabled and the Server has Authentication Mode as "Mixed" – aRip Jan 16 '20 at 11:39
  • 1
    could you share your connection string? Set Integrated Security to false if you are going to be providing the username and password.if possible put your connection string inside of the web.config file - it is more secure and reusable. When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. – Jalpa Panchal Jan 17 '20 at 05:46
  • 1
    Make sure you enabled windows authentication in IIS for PHP site and others will be disabled.Your iis application pool is running under integrated pipeline mode and application pool identity is set to the network service.In your SQL server create a login for the iis server name:domainname\iisservername$.map domainname\iisservername$ to db_datareader privilege for $dbname database – Jalpa Panchal Jan 17 '20 at 05:52
  • Does this answer your question? [SQL Connection Error: System.Data.SqlClient.SqlException (0x80131904)](https://stackoverflow.com/questions/26135346/sql-connection-error-system-data-sqlclient-sqlexception-0x80131904) – Michael Freidgeim Aug 18 '21 at 07:53

0 Answers0