Service Principal Names (SPN): Solving the "Cannot Generate SSPI Context" Mystery
Section titled “ Service Principal Names (SPN): Solving the "Cannot Generate SSPI Context" Mystery”You've deployed Nodinite across several servers: the Web Client on IIS, the Logging and Monitoring Services on an application server, and the databases on SQL Server. You select Test Connection and get:
"Cannot generate SSPI context"
Or users open the Web Client and get a login prompt instead of signing in automatically. Or a linked server query fails with:
"Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'"
All three symptoms usually share one root cause: a missing, duplicate, or misplaced Service Principal Name (SPN), which stops Kerberos authentication from working across server boundaries.
SPNs show up in two different places in a Nodinite installation, and the two problems are related but not the same:
- SQL Server SPNs (
MSSQLSvc/...) - Nodinite services and SQL Server instances authenticating to each other, including linked server hops between the Configuration Database and Log Databases. - IIS HTTP SPNs (
HTTP/...) - users' browsers and API clients authenticating to IIS-hosted Nodinite services: the Web Client, Web API, Log API, Logging Service, Monitoring Service, MCP Endpoint, and Pickup Service.
This page is the hub. It explains the shared concepts and commands once, then sends you to the guide for your problem:
- SQL Server SPNs (MSSQLSvc) - default and named instances, failover clusters, Always On, linked servers, and delegation
- HTTP SPNs for IIS - Web Client hostnames, web farms,
useAppPoolCredentials, and HTTP SPN ownership conflicts
What Goes Wrong Without Proper SPNs
Section titled “ What Goes Wrong Without Proper SPNs”- Deployment delays - installations that work on a single developer machine fail in multi-server production environments.
- Silent fallback to NTLM - systems fall back to the weaker NTLM protocol without warning, which creates compliance gaps and, for IIS, slow page loads.
- Intermittent failures - Kerberos works on one cluster node or web farm node but not another.
- Linked server breakdowns - the Configuration Database connects, but queries to remote Log Databases fail as anonymous logon.
- Post-failover surprises - a cluster or Availability Group fails over, and applications can't authenticate to the new active node.
- Unexpected login prompts - the Web Client asks for credentials instead of signing users in transparently.
Understanding SPNs and Kerberos
Section titled “ Understanding SPNs and Kerberos”An SPN is a unique identifier in Active Directory that maps a service instance, such as MSSQLSvc/sql-prod-01.contoso.com:1433 or HTTP/nodinite.contoso.com, to the account the service runs as. When a client wants to connect, it asks the Domain Controller for a Kerberos ticket for that SPN. The Domain Controller encrypts the ticket with the key of the account that owns the SPN, so only that service can read it.
That gives Kerberos two hard requirements:
- Exactly one owner - each SPN must exist on exactly one account in the forest. A missing SPN makes Kerberos fail or fall back to NTLM; a duplicate SPN makes it fail.
- The right owner - the SPN must be on the account the service actually runs as. If the ticket is encrypted for another account, the service can't decrypt it.
Diagram: the two SPN paths in a Nodinite installation. Blue nodes are the IIS path (HTTP SPN for the Web Client and Web API); orange nodes are the SQL Server path (MSSQLSvc SPN and delegation); purple is Active Directory, which both paths depend on.
Key Components Explained
Section titled “Key Components Explained”| Component | Role | Requirement |
|---|---|---|
| Domain Controller (KDC) | Issues Kerberos tickets and looks up which account owns an SPN | Reachable from clients and servers; time in sync |
| Service account | The identity a service runs as (SQL Server service, IIS application pool, Windows service) | Domain account or gMSA for distributed Kerberos |
| SPN | Maps serviceclass/host[:port] to the service account |
Registered once, on the correct account |
| Client | Requests a ticket for the SPN built from the name it connects to | Must connect with a name that has an SPN |
| Delegation | Lets a service forward the user's identity to another service | Needed for double hops, such as linked servers |
SQL Server SPNs vs IIS HTTP SPNs
Section titled “ SQL Server SPNs vs IIS HTTP SPNs”Both use the same Active Directory mechanism and the same setspn tool, but they break in different ways and get fixed in different places.
| Aspect | SQL Server (MSSQLSvc) |
IIS (HTTP) |
|---|---|---|
| Who authenticates | Nodinite services, Web API, and SQL Server itself (linked servers) | Users' browsers and API clients |
| SPN format | MSSQLSvc/host[:port or instance] |
HTTP/hostname, even when the site uses HTTPS |
| Names to register | Every node, cluster, and listener name, with port and instance variants | Every hostname clients type: DNS alias and machine name, short and FQDN |
| SPN owner | SQL Server service account | IIS application pool account, or the computer account for built-in identities |
| Server-side settings | None for SPNs; delegation for linked servers | useKernelMode and useAppPoolCredentials in IIS Windows Authentication |
| Can register itself | Yes, if the service account has the rights; otherwise a Domain Admin registers it | No for domain accounts; a Domain Admin registers it |
| Typical symptom | "Cannot generate SSPI context", anonymous logon on linked servers | Login prompt, 401 Unauthorized, slow pages from NTLM fallback |
| Typical special case | Failover clusters and Always On listeners on different ports | Machine-name URL conflicting with the computer account's HOST/ SPN |
| Validation tool | Microsoft Kerberos Configuration Manager for SQL Server | klist, browser Intranet Zone, setspn -Q |
| Full guide | SQL Server SPNs (MSSQLSvc) | HTTP SPNs for IIS |
Which Guide Do You Need?
Section titled “Which Guide Do You Need?”| Symptom | Start here |
|---|---|
| "Cannot generate SSPI context" when a Nodinite service or tool connects to SQL Server | SQL Server SPNs |
Linked server queries fail with NT AUTHORITY\ANONYMOUS LOGON |
SQL Server SPNs, then Trusted for delegation |
| Kerberos fails after a cluster or Always On failover | SQL Server SPNs |
| Login prompt or 401 in the Web Client | HTTP SPNs for IIS |
| Login prompt after upgrading from v6 to v7 | Kerberos Transparent Login After v7 Upgrade |
| Web Client is slow but no login prompt appears | NTLM vs Kerberos Authentication |
setspn -S fails with 0x21c7/8647 |
The duplicate SPN error section under Shared setspn Commands below, then the matching guide |
When Is SPN Registration Required?
Section titled “ When Is SPN Registration Required?”You need SPNs when Windows authentication crosses a machine boundary, or when a service runs as a domain account:
- ✅ Required - NTLM is disabled (Kerberos-only policy)
- ✅ Required - Nodinite and SQL Server are on different machines
- ✅ Required - SQL Server runs as a domain account or gMSA
- ✅ Required - an IIS application pool runs as a domain account, for example the v7 Web Client, Web API, or Log API published on a DNS alias
- ✅ Required - Linked Servers connect to remote SQL Server instances, or another double-hop scenario needs Trusted for delegation
- ✅ Required - SQL Server failover clusters or Always On Availability Groups
- ✅ Required - load-balanced IIS web farms serving the Web Client
You don't need to register SPNs yourself when:
- ❌ Not required - BizTalk, SQL Server, and Nodinite all run on one machine with built-in accounts
- ❌ Not required - you use SQL Server authentication instead of Windows authentication
- ❌ Not required - the IIS application pool uses ApplicationPoolIdentity or Network Service and users browse to the machine name; the computer account's built-in
HOST/SPN covers it
End-to-End Example: Multi-Tier Deployment with NTLM Disabled
Section titled “End-to-End Example: Multi-Tier Deployment with NTLM Disabled”The Web Client runs on an IIS server, the Monitoring and Logging Services on an application server, and SQL Server on a database server. NTLM is disabled. This deployment needs SPNs from both guides:
| SPN | Owner account | Covered in |
|---|---|---|
HTTP/nodinite.contoso.com |
IIS application pool domain account | HTTP SPNs for IIS |
HTTP/nodinite |
IIS application pool domain account | HTTP SPNs for IIS |
MSSQLSvc/sql-prod-01.contoso.com |
SQL Server service account | SQL Server SPNs |
MSSQLSvc/sql-prod-01.contoso.com:1433 |
SQL Server service account | SQL Server SPNs |
| More for named instances, clusters, listeners, and web farm nodes | As above | The matching guide |
Service Account Requirements
Section titled “ Service Account Requirements”These rules apply to every account that owns an SPN, whether it runs SQL Server, an IIS application pool, or a Windows service.
| Requirement | Description |
|---|---|
| Domain account or gMSA | Use a dedicated Active Directory account or gMSA, not LocalSystem, NetworkService, or NT SERVICE\..., for distributed Kerberos and delegation |
| SPN registration rights | Either the account may register its own SPNs, or a Domain Admin registers them manually |
| Not sensitive | Account is sensitive and cannot be delegated must not be checked in Active Directory when the account takes part in delegation |
| Trusted for delegation | Configure Trusted for delegation for linked servers and other double hops |
| Log on as a service | Windows services need the Logon as a Service right |
Shared setspn Commands
Section titled “ Shared setspn Commands”Both guides use the same commands. They're listed once here; the guides show only the SPN values for their scenario.
| Task | Command |
|---|---|
| Register an SPN, after checking for duplicates | setspn -S <serviceclass>/<host> <DOMAIN\account> |
| List the SPNs on an account | setspn -L <DOMAIN\account> |
| Find which account owns an SPN | setspn -Q <serviceclass>/<host> |
| Find duplicate SPNs in the forest | setspn -X |
| Remove an SPN from an account | setspn -D <serviceclass>/<host> <DOMAIN\account> |
| Clear cached Kerberos tickets on a client before retesting | klist purge |
| Show cached Kerberos tickets on a client | klist |
:: Register an SPN (SQL Server example)setspn -S MSSQLSvc/sql-prod-01.contoso.com CONTOSO\svc-sql-prod
:: Verifysetspn -L CONTOSO\svc-sql-prodExpected result:
Registered ServicePrincipalNames for CN=svc-sql-prod,OU=Service Accounts,DC=Contoso,DC=com: MSSQLSvc/sql-prod-01.contoso.com:1433 MSSQLSvc/sql-prod-01.contoso.comError 0x21c7/8647: SPN Value Is Not Unique Forest-Wide
Section titled “Error 0x21c7/8647: SPN Value Is Not Unique Forest-Wide”If setspn -S returns:
Failed to assign SPN ... error 0x21c7/8647The operation failed because SPN value provided for addition/modification is not unique forest-wide.Active Directory already has an owner for that SPN. To resolve it:
- Find the owner with
setspn -Q <serviceclass>/<host>for both the short name and the FQDN, and runsetspn -Xto list all duplicates. - If the owner is already the intended account, do nothing; the SPN is in place.
- If the owner is a stale or wrong account, for example after a server or account migration, remove the SPN from that account with
setspn -D, then add it to the correct account withsetspn -S.
Other Services: BizTalk Host Instances
Section titled “ Other Services: BizTalk Host Instances”When BizTalk Host Instances run as custom domain accounts and are accessed with Kerberos, register their SPNs with the same setspn -S pattern, substituting the host instance account and host name:
setspn -S BTSSvc/biztalk-host01.contoso.com CONTOSO\svc-biztalk-hostExternal References
Section titled “ External References”- Register a Service Principal Name for Kerberos Connections
- Understanding Kerberos Double Hop
- Microsoft Kerberos Configuration Manager for SQL Server
- Setspn command reference