Pcornel
Browse topics
Options
Recent
Favorites
Identity · Technical reference

Service Accounts

Direct answer

A service account is an identity used by software rather than a person: a Windows service, scheduled task, application pool, script or cloud workload. Modern platforms replace static passwords with managed identities (gMSA/dMSA in AD, managed identities in Azure).

When to use this

Use it whenever software must authenticate to another system. Pick the managed option the platform offers before falling back to a user account with a stored password.

First 30 seconds

1. Which identity does the workload actually run as?

2. Is it a managed identity type (gMSA, dMSA, managed identity) or a password account?

3. Can this host or resource retrieve/use it?

4. Which rights does it have, and who owns it?

5. When was its secret last rotated?

Operational verification

workload → configured identity (account, gMSA, managed identity) → credential retrieval (KDS, IMDS, vault) → authentication (Kerberos/token) → target authorization → audit

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Active Directory (Windows Server 2012+ for gMSA, Windows Server 2025 for dMSA) and Microsoft Entra / Azure managed identities.
Applicability is projected only from persisted Topic profile and Command metadata.
At a glance

Operational reference

Fast context before you go deeper.

PlatformActive Directory (Windows Server 2012+ for gMSA, Windows Server 2025 for dMSA) and Microsoft Entra / Azure managed identities.
Key commandTest-ADServiceAccount -Identity gmsa-web
Scope / prerequisiteUse it whenever software must authenticate to another system. Pick the managed option the platform offers before fallin…
What next?2 suggested next steps
Evidence0
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Read-only Verification Verify boundary
# gMSAs and which hosts may retrieve their passwords
Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword, ServicePrincipalNames |
  Select-Object Name, PrincipalsAllowedToRetrieveManagedPassword, ServicePrincipalNames

# On the host that runs the service
Test-ADServiceAccount -Identity gmsa-web          # True = this host can use it

# User accounts with SPNs (Kerberoastable) and their password age
Get-ADUser -Filter {ServicePrincipalName -like "*"} -Properties ServicePrincipalName, PasswordLastSet |
  Select-Object SamAccountName, PasswordLastSet

setspn -L DOMAIN\svc-sql                          # SPNs on one account
# Azure: user-assigned managed identities and what they can do
az identity list --query "[].{name:name, principalId:principalId}" --output table
az role assignment list --assignee <principalId> --all --output table

Test-ADServiceAccount returning False usually means the host is not in the allowed group (or has not picked up the new membership — reboot or klist -li 0x3e7 purge).

Step 2 Common mistakes Narrow the fault
  • One shared service account for many applications.
  • Domain user service accounts with SPNs, RC4 allowed and passwords that never change.
  • Granting Domain Admin, Owner or Global Administrator to a workload identity.
  • Storing service account passwords in scripts, configuration files or repositories.
  • Deleting an old service account before confirming nothing still uses it — check logons and SPNs first.
Step 3 Troubleshooting Narrow the fault

Service fails to start with a logon error after switching to gMSA. Check Test-ADServiceAccount on that host, that the service account name ends in $, that the password field is empty, and that the account has Log on as a service.

Kerberos to the service fails (falls back to NTLM). SPN missing, on the wrong account, or duplicated (setspn -X lists duplicates).

Application stops working on a specific date. An Entra client secret or certificate expired, or an AD account password expired. Check expiry dates before changing anything else.

Managed identity gets 403 from the target. The identity exists and got a token, but has no role assignment on the target resource or scope — or the assignment has not propagated yet.

Key points

One service account per workload, least privilege, no interactive logon, an owner and a rotation story. AD user accounts with SPNs and old passwords are Kerberoasting targets. gMSA rotates passwords automatically; dMSA (Windows Server 2025) binds the account to machine identity; Azure managed identities have no secret you can see.

Key checks
  • Get-ADServiceAccount -Filter * -Properties PrincipalsAllowedToRetrieveManagedPassword — gMSAs and who may use them.
  • Test-ADServiceAccount <name> on the host — can this host use the gMSA?
  • setspn -L <account> — SPNs registered on an account.
  • Get-ADUser -Filter {ServicePrincipalName -like "*"} -Properties PasswordLastSet — user accounts with SPNs and old passwords.
  • az identity list / Enterprise applications (managed identities) — cloud workload identities.
ReferenceWhat it is2 sections · depth on demand

Direct Answer

A service account is a non-human identity that software runs as. The safest choice is the managed type each platform offers: gMSA in Active Directory (Windows manages and rotates the password; only allowed hosts can retrieve it), dMSA in Windows Server 2025 (the account is bound to machine identity, and its secret cannot be retrieved off the domain controller), and managed identities in Azure (Entra service principals whose credentials you never see). Use a plain user account with a stored password only when nothing else works, and then give it an owner, least privilege, no interactive logon and a long random password that is rotated.

Scope and canonical references

This Topic owns the cross-platform view of non-human identities.

ReferenceImportant terms & boundaries1 section · depth on demand

In depth

Types of service identity

TypePlatformCredentialNotes
Domain user accountADStatic password set by an adminMost common, most abused; Kerberoastable if it has an SPN
sMSAADManaged by WindowsOne computer only
gMSAAD (2012+)Computed by DCs from the KDS root key; rotated automatically (30 days by default)Multiple hosts; hosts listed in PrincipalsAllowedToRetrieveManagedPassword
dMSAAD (Windows Server 2025)Randomised keys held by the DC; machine-bound via Credential GuardCan replace a legacy account; password logon to the old account is blocked
Service principalEntra IDClient secret or certificateCreated for app registrations; secrets expire and must be renewed
Managed identityAzure / EntraNone visible; tokens from the platformSystem-assigned (lives and dies with one resource) or user-assigned (shared, independent lifecycle)
Local system accountLinuxNone (no login shell)Runs daemons; authenticates elsewhere with keys or Kerberos keytabs

gMSA in practice

A KDS root key must exist in the forest (Add-KdsRootKey; allow time for replication). Create the account with New-ADServiceAccount -Name <name> -DNSHostName <fqdn> -PrincipalsAllowedToRetrieveManagedPassword <host-group>, add SPNs with -ServicePrincipalNames if the service needs them, run Install-ADServiceAccount and Test-ADServiceAccount on each host, and configure the service to log on as DOMAIN\name$ with an empty password. Make sure the account supports AES Kerberos encryption types.

dMSA (Windows Server 2025)

A dMSA can be created standalone or migrated from an existing service account (Start-ADServiceAccountMigration, Complete-ADServiceAccountMigration). Authentication is tied to the device identity, so a stolen password is of no use, which counters Kerberoasting. Every machine using the account must support dMSA; Microsoft recommends leaving a migration in the started state for several ticket lifetimes before completing it. A gMSA cannot be migrated to a dMSA.

Why SPN user accounts are risky

Any domain user can request a service ticket for any SPN. The ticket is encrypted with a key derived from the service account's password, so a weak or old password can be cracked offline (Kerberoasting). Managed accounts have long random secrets; for remaining user accounts use 25+ character random passwords, AES only, and monitor for RC4 ticket requests.

Lifecycle rules

  • One identity per workload — shared accounts make audit and revocation impossible.
  • Record an owner, purpose and the systems that use it.
  • Deny interactive and remote desktop logon for service accounts.
  • Grant the minimum rights on the target, not Domain Admin or Owner "to make it work".
  • Review and remove identities whose workload is gone; expired Entra secrets are a sign of an orphan.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
non-human identityworkload identitydelegated managed service accountdmsamanaged identitykerberoasting service account
Confirmation

Confirm action

Continue?