May 11 2022 09:57 AM
May 11 2022 09:57 AM
We have several SQL Server Systems located in different areas. My job involves creating reports that can come from any of our servers. The system we use for automating these reports only allow for 1 connection to SQL Server so I've created Views on our local Server that pulls data from the other SQL Servers using linked Servers. However, I'm having a problem with 1 Server the connection keeps failing. That Server uses windows authentication and I have no problem connecting through SSMS but the linked server connection Fails saying the Login Failed for user NT AUTHORITY\ANONYMOUS LOGIN. But I've specified to use my windows login. Anybody have any thoughts?
May 11 2022 07:18 PM - edited May 11 2022 07:19 PM
Yes, this behaviour is normal and commonly encountered in three tier (or more) architectures. What you'd be looking to configure is something called Kerberos Constrained Delegation (or KCD for short.)
KCD is a Windows concept (a bit simplified there, but let's stick to the Microsoft context), not an SQL concept, and you'll find it's frequently mentioned in the IIS/web server context. That said, because it's a Windows concept, the documentation on how to configure it is the same for SQL Server.
Here's a short version of what's different between your SMSS test scenario and your production scenario.
SMSS only involves a single hop for authentication as your Kerberos ticket is created on the SQL host itself. Single hops just work out of the box, which is why your linked server definition works when using SMSS, since it's only then the single hop from the SQL host to the remote SQL host linked via the linked server definition.
Your production scenario is different, since it involves two hops:
And this is where KCD comes in, and without it - and it's "off" by default - your Kerberos ticket created on the application host only makes it as far as the central SQL Server host (i.e. point 1.) Because the central host is not permitted to pass that ticket to the remote SQL host, you run into the "anonymous" authentication issue you've mentioned.
By enabling KCD (involves configuration of both the SQL Server database service account as well as the account being used by the application host to log into the central SQL Server), you're providing "approval" for the central SQL Server host to take the application host's Kerberos ticket and forward it along to the remote SQL Server host, thereby completing the second hop and resolving your "anonymous" authentication issue.
Here's some additional reading that covers the concepts and action items.
In short though, you want to:
Be aware that if the central SQL Server and/or the application host are using a credential such as "Network Service", "LocalSystem", "SYSTEM", etc. then these built-in references resolve back to the actual computer account within Active Directory.
For example, if my central SQL Server is named SQL01 and my application host is named APP01, and they both operate under the "Network Service" security principal, then for step 1 above, I'm editing the computer account for SQL01 in Active Directory, and for step 2, I'm editing the APP01 computer account from Active Directory.