Active Directory Series

🔁 The Top 1% Hands-On for Solving the "Double Hop Problem" With Kerberos Constrained Delegation

Introduction

This article is part of the Top 1% Series Complete Article Guide, the 32nd article in the Active Directory Series.

Prerequisites

The Big Picture

This hands-on consists of four steps.

graph LR
    Step1["Step1<br/>Prepare SPNs for the<br/>web server and SQL server"]
    Step2["Step2<br/>Deliberately reproduce<br/>the double hop problem"]
    Step3["Step3<br/>Configure constrained<br/>delegation"]
    Step4["Step4<br/>Confirm the problem<br/>is resolved"]
    Step1 --> Step2 --> Step3 --> Step4

Hands-On Steps

Step 1: Set up the prerequisites for the web server and SQL server

Assume IIS is running on a server called WebSrv, and SQL Server is running on a server called SqlSrv (IIS’s service account runs as the domain account svc-web). First, confirm SQL Server’s SPN is correctly registered on the account running that service.

setspn -L svc-sql

If you see an SPN like MSSQLSvc/SqlSrv.example.com:1433, you’re set.

Step 2: Deliberately reproduce the double hop problem

Build a web application on IIS on WebSrv with Windows authentication enabled, and have a user taro log into it from their browser. From within this web application’s code, attempt to connect to SQL Server using taro’s own permissions, and you’ll hit an error like this:

Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

This is the so-called “double hop problem.” On the first hop, from the client (browser) to the web server, taro’s Kerberos credentials pass through correctly. But on the second hop, from the web server to the SQL server behind it, the web server cannot impersonate taro to reach the SQL server unless it has been explicitly permitted to “forward” taro’s credentials. Kerberos is designed, by default, to never forward received identity information on to another server on its own — so this denial is exactly the correct, intended behavior, not a bug.

Step 3: Configure constrained delegation

To solve this, you need to explicitly register a setting in AD DS: “WebSrv (more precisely, the service account svc-web running on WebSrv) is permitted to reach SqlSrv’s SQL Service on taro’s behalf.”

Set-ADUser -Identity "svc-web" -Add @{"msDS-AllowedToDelegateTo" = @("MSSQLSvc/SqlSrv.example.com:1433")}
Set-ADAccountControl -Identity "svc-web" -TrustedToAuthForDelegation $true

The single most important thing here is that the msDS-AllowedToDelegateTo attribute explicitly enumerates, one by one, exactly which destination SPNs delegation is permitted to. svc-web is only permitted to impersonate taro toward the SQL Service listed here — it can’t freely impersonate them toward any arbitrary service. This is exactly why it’s called “constrained” delegation.

Step 4: Confirm the problem is resolved

From the web application, try connecting to SQL Server as taro again. This time, instead of ANONYMOUS LOGON, you should confirm you can log into SQL Server with taro’s own permissions. Checking SQL Server’s own audit log, the connecting user should now be recorded as taro themselves, not svc-web.

What a Pro Sees Here (Top 1% Understanding)

Why CredSSP and NTLM aren’t the right fix for this problem

Search for the double hop problem, and you’ll also find solutions involving CredSSP (the Credential Security Support Provider) or RDP-based delegation. But CredSSP works by temporarily holding something close to the user’s actual password on the intermediate server, which tends to widen the blast radius if that intermediate server is ever compromised, compared to Kerberos constrained delegation. What makes Kerberos constrained delegation superior is that it never relays raw, sensitive information like a password at all — it works entirely through handing off tickets issued by the KDC. And NTLM authentication doesn’t support the concept of delegation at all, so if you’re hitting the double hop problem on a configuration using NTLM, the first step is to reconfigure things so Kerberos authentication is actually being used in the first place.

The difference between constrained delegation and the newer resource-based constrained delegation

What we configured here is traditional constrained delegation, where the delegating side (svc-web) registers “where it’s allowed to delegate to.” Separately, Windows Server 2012 and later also support resource-based constrained delegation, which flips that around: the destination side (the SQL server) registers “which accounts it will accept delegation from.” Its advantage is that the destination’s administrator alone can complete the configuration, without needing administrative rights over the delegating side’s domain — making it easier to support delegation across forest boundaries too. In practice, which one you choose often comes down to whether the same person or team administers both the delegating and destination sides.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. You configured delegation, but you’re still hitting an ANONYMOUS LOGON error: Check that the SPN string registered in msDS-AllowedToDelegateTo exactly matches the SPN actually registered on the SQL Server side.
  2. You configured delegation, but Kerberos authentication isn’t actually being used at all (it’s falling back to NTLM): Check IIS’s Windows authentication provider settings, and confirm Kerberos is enabled and the SPN is registered correctly.
  3. Set-ADAccountControl fails to enable TrustedToAuthForDelegation: Check whether you have sufficient permissions on that account, and whether the domain functional level supports constrained delegation.

Summary

Takeaways to Apply Today

  1. When you hit an error like ANONYMOUS LOGON, suspect the double hop problem first.
  2. When configuring delegation, enumerate only the services actually needed in msDS-AllowedToDelegateTo, keeping the delegation target as narrow as possible.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).