Jamal Darbo// Security PortfolioPortfolio v1
Portfolio Blog
Back to blog

Identity & Access

How Kerberos knows which service you mean

How Service Principal Names connect the destination a client requests to an Active Directory account and the key that protects its service ticket.

Kerberos series: view the reading order

In my previous article, I explained why a client can use a Kerberos ticket without decrypting its protected contents. The KDC encrypts the service ticket using a key associated with the destination service’s account, and the receiving service uses that key to process it. But this leaves another part of the process to explain: how does the KDC know which account belongs to the service the client wants to reach?

When you open Remote Desktop, you usually enter a computer name. You do not normally specify the Active Directory account associated with the RDP service, or tell Windows which encryption key to use. Kerberos connects these pieces through a Service Principal Name, commonly called an SPN. It identifies a service instance and associates it with an account in Active Directory, allowing the client to request authentication without knowing that account’s name.

From a server name to a service identity

Suppose Jamal wants to connect to a server named rdp01.lab.example. From his perspective, he is opening a remote session to that computer. For Kerberos, however, the destination is more specific: the Remote Desktop service associated with that name. An SPN for this connection would look something like this: TERMSRV/rdp01.lab.example. The TERMSRV component identifies the service class, while rdp01.lab.example identifies the host. Windows normally registers RDP SPNs using both the short computer name and the fully qualified name on the server’s computer account.

The client application, or the authentication components it uses, supplies the target SPN. It can construct this name using information such as the destination entered by the user, application configuration, or directory data. The application knows the kind of service it is connecting to and which naming format that service expects. The KDC therefore does not discover the intended service by inspecting an RDP connection or guessing from a destination port: the client identifies the requested service in its ticket request.

The structure of an SPN can include more than a service class and hostname. Some services include a port or another identifying component to distinguish service instances. For example, a SQL Server connection over TCP commonly uses a name such as MSSQLSvc/sql01.lab.example:1433. These naming conventions depend on the service and its client software. An SPN is not simply a network address with the application’s name added to it.

Jamal enters rdp01.lab.example, the RDP client identifies TERMSRV/rdp01.lab.example and requests a ticket for that SPN from the KDC
The client turns the intended destination into a service identity for Kerberos.

The account behind the name

In Active Directory, SPNs are stored in an account’s servicePrincipalName attribute. That account might be a computer account or a dedicated account used by an application. In our RDP example, the SPN would normally belong to the computer account RDP01$. The SPN and the account name serve different purposes: TERMSRV/rdp01.lab.example identifies the service the client requested, while RDP01$ identifies the account associated with it. Several SPNs can belong to the same account, but a particular SPN must not identify multiple different accounts.

This association connects service naming to the encryption described in the previous article. In a normal service-ticket exchange within the domain, the KDC resolves the requested service identity to its account and uses the appropriate account key to protect the ticket’s encrypted contents. The service must have access to the corresponding key to decrypt the ticket and retrieve the client-service session key. The client receives the ticket and its own separately protected session-key information, then presents the ticket with an authenticator when connecting to the service.

The KDC resolves TERMSRV/rdp01.lab.example to RDP01$, uses the account's long-term key to encrypt the service ticket and the RDP service uses the corresponding key to decrypt it
The SPN connects the requested service to the account whose key protects the ticket.

There is a Windows-specific detail worth understanding here. Some common service classes can map to the computer account’s HOST SPN, so every service name does not necessarily require its own explicit entry. This makes the lookup slightly more involved than searching for an identical string in every case. But the underlying requirement remains the same: the KDC must resolve the requested service to the appropriate account.

An SPN also does not create a separate encryption key for every service name. When several SPNs belong to the same account, they refer to the same account identity and its key material. Different service names therefore do not automatically mean different cryptographic trust boundaries. This is why the account behind an SPN matters just as much as the name visible in the request.

Why the name you connect to matters

It is easy to treat a hostname as a convenient label for an IP address, but that name can also influence the identity used for authentication. Suppose rdp01.lab.example and remote.lab.example both resolve to the same server. A network connection to either name might reach the same machine, yet the client could request a different SPN depending on the name it uses. If it requests TERMSRV/remote.lab.example, that identity must also resolve correctly in Active Directory. The exact behaviour depends on how the application constructs or canonicalizes the name, so two names reaching the same address do not guarantee identical Kerberos behaviour. Microsoft identifies DNS and other client naming inputs as relevant sources when investigating an incorrectly requested SPN.

This distinction separates network reachability from service identity. DNS helps the client locate a destination. The SPN allows Kerberos to associate the requested service with an account. Creating a DNS alias alone does not establish that association. Likewise, a server answering on the expected port does not prove that it possesses the key associated with the identity the client requested.

Connecting by IP address introduces another difference. By default, Windows does not attempt Kerberos authentication when the target hostname is an IP address, and another enabled authentication method such as NTLM may be used instead. Windows supports explicitly configured IP-based SPNs, but that requires additional configuration. A successful connection to an IP address therefore does not establish that Kerberos was used, even when connecting to the same server by name would use it.

When the naming and account association are incorrect, authentication can fail at different stages. If the KDC cannot identify the requested service or cannot resolve it uniquely, ticket issuance can fail with errors such as KDC_ERR_S_PRINCIPAL_UNKNOWN or KDC_ERR_PRINCIPAL_NOT_UNIQUE. If a ticket is issued using an account key the receiving service does not possess, the service cannot process it successfully. These are different problems: one concerns identifying the ticket’s intended recipient, while the other concerns the recipient’s ability to use the key selected for it.

For me, this makes the SPN an important connection between the names we use and the trust Kerberos establishes. The client supplies a service identity, Active Directory associates that identity with an account, and the account’s key makes the ticket usable by the intended service. So, Kerberos knows which service you mean because the client names it, and that name must lead to the correct account and key.