Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

KRB_AP_ERR_MODIFIED: duplicate SPNs and the wrong account behind a name

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Users reach a web site, file share or application that uses Windows sign-in and get asked for a username and password, or get access denied. On the client, the System log shows:

Event ID: 4 · Source: Kerberos · Type: Error The kerberos client received a KRB_AP_ERR_MODIFIED error from the server host/myserver.domain.com. This indicates that the password used to encrypt the kerberos service ticket is different than that on the target server.

(Microsoft Learn, KRB_AP_ERR_MODIFIED)

In plain terms: the client asked a domain controller for a ticket to a service name, the domain controller encrypted that ticket for one account, and the server that received it is running as a different account, so it cannot open the ticket.

What you see

  • Password prompts or access denied for a service that normally signs people in silently.
  • Kerberos event 4, KRB_AP_ERR_MODIFIED in the client's System log, naming the service principal name (SPN) it asked for, for example host/myserver.domain.com or http/app.domain.com.
  • Sometimes it only fails through one name (an alias, a load-balanced name) and works through another.
  • In a network trace, KerberosV5:KRB_Error - KRB_AP_ERR_MODIFIED, sometimes alongside KDC_ERR_PRINCIPAL_NOT_UNIQUE (Microsoft Learn, Kerberos troubleshooting guidance).

Why it happens

Every Kerberos service is found by its SPN, a name such as http/app.domain.com stored on one Active Directory account. The domain controller encrypts the ticket with that account's password. The service can only read it if it runs as that same account.

Microsoft lists these causes (Microsoft Learn, Kerberos troubleshooting guidance; Microsoft Learn, KDC_ERR_PRINCIPAL_NOT_UNIQUE):

  • The SPN is on more than one account, or on the wrong one. One SPN can belong to only one account. Microsoft calls out a common case: a service is changed to run under a custom service account, but the SPN is still on the computer account too (or only there).
  • The service is not using the account the SPN belongs to, for example an application pool or Windows service whose identity was changed.
  • The name resolves to a different server. A DNS alias or load-balanced name that points at a server other than the one holding the SPN. Microsoft's event page notes this is common with load balancing across several addresses or network adapters.
  • Identically named computer accounts in the client's domain and the target's domain (from the event text).
  • Clocks out of sync or a non-unique service account name across domains in a multi-domain forest can also produce this error, which is why Microsoft says to look at the related events too.

How to prove the cause

Read-only checks. The duplicate search needs at least Enterprise Admin rights according to Microsoft.

1. Get the exact SPN. Take it from the event 4 text, or from a network trace of the failing request.

2. Find every account holding it.

setspn -Q <SPN>

To search the current domain for every duplicate SPN:

setspn -T * -X

For several trusted forests, Microsoft gives setspn -X <SPN>. Duplicate searches across a forest can take a long time and a lot of memory (Microsoft Learn, KDC_ERR_PRINCIPAL_NOT_UNIQUE; Microsoft Learn, setspn).

3. List what the service's own account has.

setspn -L <computer name or domain\service account>

4. Check which account the service runs as. Look at the Windows service's Log On account, or the web application pool's identity. If it is Local System or Network Service, the service uses the computer account. If it is a named domain account, the SPN must be on that account.

5. Check the name. On the client:

nslookup <name users connect to>

Make sure it resolves to the server that actually runs the service under the account holding the SPN.

6. Rule out time. Clocks must be within five minutes of the domain controller. If needed:

w32tm /resync /computer:<computer> /rediscover

The fix

Decide which account should hold the SPN (the one the service actually runs as), then make Active Directory match:

  • Remove the SPN from every other account (Microsoft Learn, KDC_ERR_PRINCIPAL_NOT_UNIQUE):

    setspn -D <SPN> <wrong account>
    
  • Add it to the right account, using -S, which checks for duplicates first (Microsoft says to use -S rather than -A):

    setspn -S <SPN> <correct account>
    
  • If the service runs as the computer account and is one of the common Windows services (such as http, cifs or w3svc), the computer's automatic HOST SPN normally covers it, and no separate SPN is needed. Add one only if the service is not in Microsoft's list (Microsoft Learn, setspn).

  • If the client asks for the wrong name, fix where it gets that name. Microsoft says DNS is a common source; custom clients may use others.

Then clear cached tickets on the client so it requests a fresh one:

klist purge

How to confirm the fix

  • setspn -Q <SPN> returns exactly one account, the one the service runs as.
  • The user reaches the service without a password prompt.
  • klist tickets on the client shows a ticket for the SPN.
  • No new Kerberos event 4 KRB_AP_ERR_MODIFIED for that SPN.

What to watch afterwards

  • Service account changes. Whenever someone changes an application pool or service to a different account, the SPN has to move with it.
  • Server moves and rebuilds. A replacement server, a new alias or a load-balanced name can leave the SPN on the old account.
  • Periodic duplicate checks with setspn -X catch problems before users do. Microsoft notes SPNs do not have to be unique across forests, but duplicates can break cross-forest sign-in.

Risks and limits

  • setspn -D on the wrong account can break a working service. Record the output of setspn -L for each account before changing anything.
  • setspn -R resets a computer's default SPNs. It is not a fix for duplicates.
  • SPNs are not case sensitive for Windows, but many non-Windows systems are. Use the exact case when the service is not on Windows.
  • Microsoft's KRB_AP_ERR_MODIFIED page was written for Windows Server 2003 and IIS 6. Its event text and causes still help; its IIS 6 settings do not apply to current IIS.

Sources

Next step

Once you know which account holds the name and which account runs the service, the fix is a small change; the care is in not breaking another service on the way. NetLeverage has looked after business servers since 2002. If sign-in prompts keep coming back after a server move or account change, talk to us through managed support with the SPN from event 4 and the output of setspn -Q.