TExcelTAD
Home › Windows & Active Directory Security › Stale and Privileged Accounts

Stale and Privileged Accounts

Every directory accumulates accounts nobody uses: people who left, projects that ended, test users from a migration, service accounts for software uninstalled years ago, computers that were thrown away without being removed. Stale accounts are attractive to attackers because nobody notices when they are used: no user complains about a strange logon, no help desk ticket follows a lockout. The other end of the scale is the set of privileged accounts, which in most domains is far larger than anyone thinks once nesting, built-in groups and service accounts are counted. The two meet in the worst finding of all: a privileged account that is also stale. This lesson measures both from a synthetic export and turns the numbers into a cleanup plan.

The attributes that tell the story

Attribute Meaning Caveat
lastLogonTimestamp last logon, replicated to all DCs updated only when older than about 14 days (minus a random 0–5 days), so it is accurate to roughly two weeks; good enough for staleness
lastLogon last logon on this DC not replicated: query every DC and take the maximum
pwdLastSet when the password was last set 0 means "must change at next logon"
userAccountControl disabled, password never expires, password not required, … (LDAP) decimal in filters
adminCount 1 once the account was in a protected group; AdminSDHolder then controls its ACL stays 1 after removal ("orphaned" admins with non-inheriting ACLs)
whenCreated, description, manager context for the owner question

Measuring the directory

The export below is shaped like Get-ADUser -Filter * -Properties lastLogonTimestamp, pwdLastSet, adminCount, memberOf, servicePrincipalName, PasswordNeverExpires converted to dates, plus a column priv with the privileged groups each account expands into (computed as in SIDs and tokens). The review date is fixed so the output is stable.

python · try it yourself
import pandas as pd

today = pd.Timestamp("2026-11-15")
users = pd.DataFrame([
    # name, enabled, last logon, password set, never expires, adminCount, privileged via, has SPN
    ("alice",        True,  "2026-11-14", "2026-09-01", False, 1, "Domain Admins", False),
    ("da-erin",      True,  "2026-11-10", "2026-06-20", False, 1, "Domain Admins", False),
    ("old-admin",    True,  "2025-02-03", "2021-04-11", True,  1, "Domain Admins", False),
    ("svc-sql",      True,  "2026-11-15", "2019-03-11", True,  0, "", True),
    ("svc-backup",   True,  "2026-11-15", "2021-06-30", True,  1, "Backup Operators", True),
    ("svc-oldcrm",   True,  "2024-08-19", "2018-01-05", True,  0, "", True),
    ("bob",          True,  "2026-11-13", "2026-10-02", False, 0, "", False),
    ("former-intern",True,  "2025-12-20", "2025-06-01", False, 0, "", False),
    ("test-migr01",  True,  None,         "2022-09-09", True,  0, "", False),
    ("helpdesk-old", False, "2023-05-05", "2023-01-01", False, 1, "", False),
    ("krbtgt",       False, None,         "2024-01-02", False, 1, "", False),
], columns=["name", "enabled", "last_logon", "pwd_set", "never_expires", "admincount", "priv", "spn"])
users["last_logon"] = pd.to_datetime(users["last_logon"])
users["pwd_set"] = pd.to_datetime(users["pwd_set"])
users["idle_days"] = (today - users["last_logon"]).dt.days
users["pwd_age"] = (today - users["pwd_set"]).dt.days

enabled = users[users.enabled & (users.name != "krbtgt")]
stale = enabled[(enabled.idle_days > 90) | enabled.last_logon.isna()]
priv = enabled[enabled.priv != ""]
checks = {
    "stale (no logon for 90+ days or never)": stale.name,
    "privileged (expanded)": priv.name,
    "privileged AND stale": priv[priv.name.isin(stale.name)].name,
    "password older than 1 year, never expires": enabled[(enabled.pwd_age > 365) & enabled.never_expires].name,
    "SPN on a user account with password older than 1 year": enabled[enabled.spn & (enabled.pwd_age > 365)].name,
    "adminCount=1 but no longer privileged (orphaned ACL)": users[(users.admincount == 1) & (users.priv == "") & (users.name != "krbtgt")].name,
}
for title, names in checks.items():
    print(f"{title:56} {len(names):2}  {', '.join(names)}")
k = users[users.name == "krbtgt"].iloc[0]
print(f"{'krbtgt password age (days)':56} {k.pwd_age}")
stale (no logon for 90+ days or never)                    4  old-admin, svc-oldcrm, former-intern, test-migr01
privileged (expanded)                                     4  alice, da-erin, old-admin, svc-backup
privileged AND stale                                      1  old-admin
password older than 1 year, never expires                 5  old-admin, svc-sql, svc-backup, svc-oldcrm, test-migr01
SPN on a user account with password older than 1 year     3  svc-sql, svc-backup, svc-oldcrm
adminCount=1 but no longer privileged (orphaned ACL)      1  helpdesk-old
krbtgt password age (days)                               1048

Turn the output into actions in order of risk:

  1. old-admin is privileged and has not logged on for well over a year, with a password from 2021 that never expires. Disable it today; if nobody objects in a few weeks, remove it from Domain Admins and delete it.
  2. Service accounts with old passwords and SPNs (svc-sql, svc-backup, svc-oldcrm): Kerberoasting candidates (Roasting). Move to gMSAs; svc-oldcrm is also stale, so find its owner or disable it.
  3. Stale ordinary accounts (former-intern, test-migr01): disable, then delete after the retention period. An account that has never logged on and never expires is usually a migration leftover.
  4. Orphaned adminCount (helpdesk-old): disabled already, but its ACL no longer inherits; clear adminCount and re-enable inheritance so the account is protected by normal OU permissions again.
  5. krbtgt with a password almost three years old: schedule the double reset (Golden and Silver Tickets).

How misuse is detected

  • Dormant account logons: 4624 (or 4768 on DCs) for an account whose previous logon was more than 90 days ago. A rule needs the previous-logon state, which the SIEM keeps as a lookup table.
  • Re-enabling: 4722 (a user account was enabled) for an account disabled in a cleanup, and 4738 changes on it; 4724 password resets on dormant accounts.
  • Privileged group changes: 4728/4732/4756 for every group that expands into a privileged SID; Microsoft Defender for Identity and similar tools alert on additions to sensitive groups.
  • Privileged count drift: the number of accounts in the "privileged (expanded)" line should be tracked over time; growth needs a reason.

How it is fixed and kept fixed

  • Joiner-mover-leaver process tied to HR: accounts are disabled on the leaving date, not when someone notices.
  • Automated staleness: a scheduled job disables enabled accounts idle for 90 days (service accounts reviewed with their owners), deletes disabled accounts after the retention period, and removes stale computer accounts.
  • Few, separate privileged accounts: each admin has a separate admin account; Domain Admins holds a handful of named people, no service accounts; built-in operator groups empty. Use Fine-Grained Password Policies to give admin and service accounts longer minimum lengths.
  • Owners for every service account (manager or a description with the system and team), reviewed yearly.
  • Just-in-time admin: group membership granted for hours through a privileged access management process (for example time-bound memberships with the Privileged Access Management optional feature, or an external PAM tool) instead of permanent membership.

Pitfalls

  • Using lastLogon from one DC. It isn't replicated; an account can look stale on DC01 while logging on daily at DC02.
  • Disabling service accounts without an owner check at 9 a.m. on a Monday. Disable in a change window, with a rollback plan; better, find the owner first.
  • Forgetting computer accounts: stale computers keep their passwords and, if still trusted for delegation or members of server groups, their rights.
  • Counting only direct members of privileged groups.

Practice

1. Why is test-migr01 flagged as stale although its idle_days is empty?

It has never logged on (last_logon is empty, so idle_days is NaN), and the rule includes "never". An enabled account that never logged on since 2022 should not exist.

2. Add a check for enabled privileged accounts whose password is older than 180 days. Which accounts does it list?

enabled[(enabled.priv != "") & (enabled.pwd_age > 180)] lists old-admin and svc-backup. da-erin (password from June 2026, 148 days) and alice don't qualify yet.

3. old-admin logs on (4624) tomorrow from WS02. What do you do?

Treat it as a likely compromise: a dormant domain admin suddenly active. Confirm with the account's last known owner, disable it, check what the session did (4688, 4672, directory changes), and look for how the credential was obtained.

Test yourself

Which attribute should a staleness report use without querying every DC?

  1. lastLogon
  2. lastLogonTimestamp
  3. badPwdCount
  4. logonCount

What does adminCount=1 on an account that is no longer in any protected group indicate?

  1. It is still an admin
  2. An orphaned AdminSDHolder marker: its ACL may still not inherit and should be cleaned up
  3. The account is disabled
  4. Nothing at all

Which event shows a disabled account being enabled again?

  1. 4720
  2. 4722
  3. 4725
  4. 4740

Which account combination is the highest priority to fix?

  1. A stale ordinary user
  2. A privileged account that is also stale with an old non-expiring password
  3. An active user with a new password
  4. A disabled test account