The target principal name is incorrect. Unable to generate SSPI context. (Microsoft SQL Server, error: 0)
When configuring log shipping, I found that my domain account could not log in to DBR05 on another machine.
The error message is as follows
The target principal name is incorrect. Unable to generate SSPI context. (Microsoft SQL Server, error: 0)
Google, start with "incorrect target subject name"
Run first
Setspn-L XX-XX-db05
Setspn-L XX-XX-dbr05
You can see the SPN with two more MSSQLSvc heads.
The solution is to delete these two unnecessary spn as follows:
Use an ID with delete permission to do the following
Setspn-D MSSQLSvc/XX-XX-DBR05.XX.com:1433 XX-XX-dbr05
Setspn-D MSSQLSvc/XX-XX-DBR05.XX.com XX-XX-dbr05
Today, I consulted the god of the network, the reason should be that the machine was installed and registered directly to the domain.
After this, the host name is modified, which will result in the repeated registration of the same machine in the SPN domain, and you can see two more Windows in figure 1.
Therefore, from the standpoint of DBA, the acceptance of the new machine must confirm with SA whether the SPN is correct, otherwise, if you match AG with loghipping, you will be cheated to death.