Site icon Windows Active Directory

Service account design in architecture (gMSAs etc.)

Service Account Design in Architecture (gMSAs, SPNs, Delegation, and Real-World Patterns)

Service accounts are rarely “just accounts.” They’re long-lived identities that sit at the junction of authentication (Kerberos vs NTLM), authorization (AD ACLs), and operational reliability. That combination makes them both critical and dangerous: a single mis-designed service account can become a stable pivot for attackers or a recurring outage root cause.

This guide treats service accounts as an architecture problem: choosing the right account type (gMSA and friends), limiting blast radius, controlling delegation/SPNs, and building a lifecycle that doesn’t decay into “password never expires.”

What a service account is (and what it isn’t)

A service account is a non-human identity used by software to authenticate to Windows, AD, and downstream resources. Architecturally, it’s a security principal that represents an application boundary: it defines what the service can do, where it can do it, and what happens if it’s compromised.

The failure mode is predictable: “make it work” becomes “give it broad rights,” then the account lives for years, accumulates permissions, and becomes invisible. If you want a visceral reminder of how legacy permissions drift turns into real risk, read Excess Permissions: Lessons from Legacy Setups.

Account types: user vs MSA vs gMSA vs local identities

1) Traditional domain user account (the “default” that causes pain)

  • Pros: universally compatible, easy to understand.
  • Cons: password rotation is fragile, credential exposure is common, interactive logon gets abused, and “temporary” admin rights become permanent.

If you’re using a normal domain user as a service account, you need explicit guardrails (logon restrictions, monitoring, lifecycle). Otherwise you end up compensating forever.

2) Standalone Managed Service Account (MSA)

  • Best for: a service on a single server.
  • Key benefit: AD-managed password rotation (no human knows the password).
  • Constraint: not designed for “same identity on many hosts.”

3) Group Managed Service Account (gMSA)

  • Best for: services running across multiple servers (farm, cluster, multiple app nodes).
  • Key benefit: password is rotated automatically and securely; multiple hosts can retrieve the managed password.
  • Hidden architectural win: gMSA enforces a host membership boundary (only approved servers can use it).

If you want a concrete, working example of gMSA setup, see Configure gMSA Defender Identity: Step-by-Step Guide. Even if you’re not deploying Defender for Identity, the pattern (allowed hosts group + gMSA + validation) is broadly reusable.

4) Built-in local identities: LocalSystem, LocalService, NetworkService, and virtual accounts

  • Best for: services that do not need a stable domain identity.
  • Key idea: if the service only needs local machine privileges (or can authenticate as the computer account), don’t invent a domain user.

A lot of environments create domain service accounts when the computer account (or a local virtual account) would have been safer and simpler. The “don’t create identities you don’t need” rule is underrated.

Decision matrix: which type should you use?

Scenario Recommended identity Why
Single Windows service on one server MSA (or virtual account) Password management without humans; minimal identity surface.
Service runs on 2+ servers (farm/cluster) gMSA One identity across many hosts with controlled password retrieval.
Legacy app cannot use MSA/gMSA Domain user (hardened) Compatibility, but requires strong controls and monitoring.
App needs Kerberos auth to a specific SPN gMSA or domain user (strict SPN ownership) Stable identity + controlled SPN registration and delegation boundaries.
Service only needs to access network resources as the host Computer account (HOST$) / NetworkService Removes a whole class of “service account sprawl” risk.

Two principles keep you sane:

  1. Default to the least “identity weight” that still meets the technical requirement.
  2. One service boundary → one principal (avoid sharing accounts across unrelated services).

gMSA architecture patterns that actually scale

Pattern A: “One gMSA per application boundary”

Treat each gMSA as the identity of a specific application boundary (e.g., “Payroll API”, “Inventory Job Runner”). If two services have different data access, different owners, different environments, or different uptime requirements, they should not share a gMSA.

Pattern B: “Allowed hosts group is the real security boundary”

gMSA security is not only about password rotation. It’s also about which hosts can retrieve the managed password. Design the PrincipalsAllowedToRetrieveManagedPassword group like a firewall rule: only the servers that must run the service belong in that group—nothing else.

Pattern C: “Environment separation”

Use separate accounts per environment (Prod/Stage/Dev). This is non-negotiable if you want real blast-radius isolation and clean audits. Mixing environments in a single service identity means a Dev compromise can become a Prod compromise.

Reference commands (example skeleton)

# Create a security group that represents allowed hosts
New-ADGroup -Name "APP1_gMSA_Hosts" -GroupScope Global

# Add app servers to the allowed hosts group
Add-ADGroupMember -Identity "APP1_gMSA_Hosts" -Members "APP1-SRV01$","APP1-SRV02$"

# Create the gMSA and allow the hosts group to retrieve the managed password
New-ADServiceAccount -Name "gMSA_APP1" `
  -DNSHostName "gMSA_APP1.contoso.local" `
  -PrincipalsAllowedToRetrieveManagedPassword "APP1_gMSA_Hosts"

# On each app server, install and test
Install-ADServiceAccount -Identity "gMSA_APP1"
Test-ADServiceAccount -Identity "gMSA_APP1"

If you want a full worked example with a real product integration, use the end-to-end walkthrough in Configure gMSA Defender Identity: Step-by-Step Guide as a template.

SPNs: design, ownership, and the “who can write SPN” trap

Service Principal Names (SPNs) are how Kerberos maps a service instance to an account. If your service uses Kerberos, SPNs are part of your identity design—not a post-install checkbox. A weak SPN design usually creates one of two problems:

  • Operational: authentication breaks intermittently due to duplicate/mis-registered SPNs.
  • Security: someone who can modify SPNs (or delegation settings) can create powerful impersonation paths.

To reason about SPNs, you need the Kerberos mental model (tickets, TGS, mutual auth). If that’s rusty, refresh it here: NTLM authentication and Kerberos Authentication Protocols Explained.

Architectural rule: separate “run identity” from “SPN ownership” only with intent

Ideally, the account that runs the service is also the account that owns the service’s SPNs. If you decouple them (for legacy reasons), document why and lock down who can write servicePrincipalName.

Guardrail: treat SPN write permission like a privileged operation

In mature environments, only a small, audited admin workflow can add or modify SPNs for service accounts. That’s not bureaucracy; it’s preventing silent identity hijacks.

Delegation & double-hop: constrain it or regret it

The moment a service needs to access a second resource on behalf of a user (classic “double hop”), delegation enters the picture. Delegation is one of the most misunderstood features in AD because it’s not just a setting— it’s an impersonation capability.

Start by understanding what the platform is actually offering on the Delegation tabs and what those options imply. These two references are especially useful for navigating the UI and its implications:

Architectural rules for delegation

  1. Avoid unconstrained delegation. If you can’t explain its blast radius in one sentence, you shouldn’t deploy it.
  2. Prefer constrained delegation to specific services. Make the allowed-to-delegate list explicit and small.
  3. Separate tiers. Never allow delegation paths that can reach Tier-0 assets indirectly.

Delegation problems are rarely “just Kerberos.” They’re usually “we let a service identity become a user impersonation gateway.” Treat the delegation configuration as part of your threat model.

OU placement, RBAC boundaries, and delegating safely

Good service-account architecture needs a home in your directory structure. Two common outcomes:

  • Good outcome: service accounts live in dedicated OUs with clear delegation boundaries and lifecycle automation.
  • Bad outcome: service accounts are scattered across user OUs, inherit random GPOs, and get managed ad-hoc.

If you want a strong blueprint for OU boundaries aligned to RBAC and blast radius, use: How to design OU for rock-solid RBAC (with Azure alignment).

Recommended OU pattern (simple and effective)

OU=Service Accounts
  OU=gMSA
  OU=MSA
  OU=Legacy (domain user-based service accounts)
  OU=Privileged Service Accounts (rare; extra controls)

Delegation pattern: manage by groups, not people

Service accounts need changes over time (SPNs, description updates, host allow-lists, rights assignments). Delegate those tasks to security groups with scoped permissions, and keep the scope tight. For an expert-level approach to doing that without creating new attack surfaces, see: How to delegate OU permissions with minimal risk.

Under the hood, this is an AD permissions problem. If your team struggles to reason about effective rights and precedence, keep this bookmarked: Active Directory Permissions Explained.

Hardening checklist: what to enforce by default

Identity controls

  • No interactive logon by default (deny locally, deny RDP, deny “log on as a batch job” unless required).
  • Separate admin identities from service identities (never use a service account for administration).
  • One account per service boundary (no shared “svc_sql” powering five unrelated apps).
  • Document owner + purpose + dependencies in the account description (treat it like a runbook pointer).

Password and authentication controls

  • Prefer MSA/gMSA to eliminate human-managed passwords.
  • If forced to use a domain user: use long random passwords and a rotation plan that won’t break production.
  • Align with domain policy strategy so service identities don’t accidentally become policy exceptions forever: How to Configure a Password Policy - An Overview & Guide.
  • Minimize NTLM dependencies and make Kerberos the steady-state where possible.

Authorization controls

  • Grant rights to groups, not accounts directly. Put the service account in a “role group” and assign rights to the group.
  • Scope permissions to resources (file shares, databases, queues) instead of broad AD rights.
  • SPN writes are privileged. Treat them like change-controlled operations.

Lifecycle: provisioning, rotation, monitoring, decommission

Provisioning (build it like a product)

  • Create from a template: naming, OU, description fields, baseline deny-logon policies.
  • Attach the account to a role group (so rights can evolve without changing the identity).
  • Record dependencies: services, scheduled tasks, IIS app pools, SPNs, delegation settings.

Rotation (make it survivable)

With gMSA/MSA, rotation is built in. With legacy user accounts, rotation is an outage generator unless you design for it. Your goal is not “rotate passwords sometimes.” Your goal is “rotation is routine and boring.”

Monitoring (assume someone will try)

Monitoring service accounts is often where identity security moves from theory to practice. At minimum, alert on:

  • Interactive logons by service accounts (unexpected logon types).
  • Membership changes in privileged groups.
  • SPN modifications, delegation setting changes, and new service accounts created outside the workflow.

If you’re running hybrid identity security controls, you can operationalize this with tooling such as Microsoft Defender for Identity, especially for unusual credential use patterns and lateral movement signals.

Decommission (the step most orgs skip)

  • Disable first, don’t delete immediately.
  • Watch for failures and residual dependencies for a defined period.
  • Remove SPNs, remove delegation entries, remove group memberships.
  • Then delete (or archive) according to policy.

If you want automation ideas for “identity hygiene” lifecycle work, this playbook-style approach is a good mental model: Automating inactive user account cleanup: AD & Entra playbook. The same staged, reversible thinking applies cleanly to service accounts.

Common failures (and how to fix them)

Failure 1: “One mega service account runs everything”

This is the fastest path to a high-blast-radius compromise. Fix it by splitting by application boundary and moving rights to role groups. Yes, it’s work. It’s also one of the highest ROI identity security changes you can make.

Failure 2: “Password never expires” becomes permanent policy

Replace human passwords with MSA/gMSA where possible. Where not possible, design a rotation workflow that can be rehearsed and rolled back. Align it with your broader password policy strategy rather than creating exceptions that never die: Active Directory Password Policies.

Failure 3: Delegation configured as a quick fix

Delegation is not a troubleshooting step; it’s an impersonation design. Treat it as architecture, constrain it aggressively, and understand what the UI settings imply: Computer Delegation tab.

Failure 4: Service accounts scattered across random OUs

Consolidate into dedicated OUs, use RBAC boundaries, and delegate management safely: OU design for RBAC and OU delegation with minimal risk.

Failure 5: Nobody knows what the account does

If your SOC can’t answer “what is this account for?” during an alert, you’ve already lost time. Make description fields mandatory: owner, system, environment, dependency list, and a link to the runbook.

Practical takeaway: your “service account architecture” in one sentence

Choose the lightest identity that satisfies the requirement (prefer gMSA/MSA), bind it to a tight host and permission boundary, constrain SPNs/delegation like privileged change, and operate it with a lifecycle (monitor → rotate → retire) instead of hope.

If you also manage a lot of these at scale, the tooling angle can help with inventory and reporting: Free Active Directory Tools.

Exit mobile version