Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot generate SSPI context exception after publishing mvc application to web server

After publishing a new version of my MVC app to our development web server I got the following error (abridged with account name redacted) :

Event code: 3005 
Account name: xxx\xxxxxxxx 
Exception type: SqlException 
Exception message: The target principal name is incorrect.  Cannot generate SSPI context. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)

What is causing the exception?

like image 379
Roland Schaer Avatar asked Nov 07 '13 16:11

Roland Schaer


People also ask

How do you resolve the target principal name is incorrect Cannot generate SSPI context?

There are a couple of solutions for this problem. You can elevate permissions and use domain admin account for your SQL Server Service (Not recommended). You can manually create an SPN for your computer that is running SQL Server and assigned that SPN to the service account of the SQL Server service on that machine.

Can not generate SSPI context?

If you get the Cannot Generate SSPI Context error from our Server Monitoring tool as shown in the figure below, we should use SQL Server Authentication instead of Windows Authentication as a login method. To fix this problem, we need to create a new SQL Server account.

What is SSPI in SQL Server?

SSPI stands for Security Support Provider Interface. The SSPI allows an application to use any of the available security packages on a system without changing the interface to use security services.


1 Answers

The issue was with a service account that we use to run our websites. I put in a request to have the accounts created and they were mistakenly set up to have the passwords expire. So everything worked great until the password expired.

Since this is a new medium priority app it was being developed in small increments over a period of several months by one developer. As a result the website did not get used very much.

The solution is to reset the password on the service account and make sure that it is set to never expire. Shut down the app pool. Update the password for the service account and then restart the app pool.

like image 183
Roland Schaer Avatar answered Oct 11 '22 22:10

Roland Schaer