Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 20 min · revision 2

How a Windows Domain Decides Who You Are

Follow a sign-in through Active Directory: the Kerberos AS and TGS exchanges, the ticket-granting ticket, service tickets and the PAC, why Windows falls back to NTLM, how LDAP and group membership build an access token, how Group Policy applies, and how Microsoft Entra Connect extends identity to the cloud. Run a small Python model that expands nested groups into a token and decodes account flags.

Contentsand lesson path

What you will learn

  • Explain how a Windows domain authenticates and authorises users and machines (Kerberos tickets, NTLM fallback, LDAP, security groups, Group Policy) and how hybrid identity extends it to a cloud directory such as Microsoft Entra ID.

01. Why it matters

Most attacks against a Windows domain are, in the end, about identity: stealing it, forging it, or using a legitimate one where it should not be. To spot that in logs, you first need a clear picture of how a domain decides who you are and what you may do. This lesson builds that model for the later lessons.

Active Directory (AD) is Microsoft's directory service. It stores users, computers and groups, and answers two questions on every access: who is this (authentication) and what may they do (authorisation). A domain is one administrative boundary inside AD, served by domain controllers (DCs), the servers that hold the directory and run the authentication services.

You need Python 3.10 or later, standard library only. The model uses made-up names and the reserved domain example.invalid; no real directory is touched.

02. Kerberos: tickets, not passwords on the wire

When you sign in to a domain-joined computer, Windows prefers Kerberos, a ticket-based protocol. Your password does not travel to each server; you prove who you are to a DC and collect tickets.

Kerberos has three parties: the client, the Key Distribution Centre (the KDC, a service on every DC) and the service, such as a file share. In the AS exchange (Authentication Service), the client proves it knows the password by encrypting a timestamp with a key derived from it (pre-authentication). The KDC replies with a ticket-granting ticket (TGT): a token encrypted with the secret key of the krbtgt account, which only DCs can read.

To open a service, the client then runs the TGS exchange (Ticket-Granting Service). It presents the TGT and names the service by its service principal name (SPN), a string such as cifs/fs01.example.invalid that names the service and its host; AD maps each SPN to the account that runs the service. The KDC returns a service ticket encrypted with that account's key, which the service decrypts and trusts without calling the DC.

A ticket issued by an AD domain controller normally carries a PAC (Privilege Attribute Certificate), a signed block listing the user's SIDs: the account's security identifier and that of every group it belongs to. The service reads the PAC to build your access token. Each ticket also records the encryption type as a hexadecimal code: 0x12 is AES256 and 0x11 is AES128, the strong modern types, while 0x17 is RC4-HMAC, an old type. Any service ticket can be taken away and attacked offline with password guesses, but RC4 makes the guessing much cheaper, because its key is the account's unsalted NT hash. You will use these codes to spot Kerberoasting later.

03. NTLM fallback, LDAP and encryption-type changes

Kerberos needs an SPN to find the right key, so it only works when the client can name the service and reach a DC. When it cannot, Windows falls back to NTLM, an older challenge-response protocol. The clearest example is reaching a server by its IP address instead of its name: with no SPN to look up, the client uses NTLM unless an administrator opts in with the TryIPSPN registry value. NTLM also appears with local accounts. It is weaker, and its responses can be relayed or cracked, so hardening reduces it. All versions of NTLM are now deprecated, and NTLMv1 was removed in Windows 11 version 24H2 and Windows Server 2025.

Directory lookups and changes, such as reading group membership or Group Policy links, travel over LDAP (Lightweight Directory Access Protocol), the query protocol for AD. A client binds to a DC, then reads or writes objects. Because an unsigned LDAP bind can be tampered with or relayed, DCs can require LDAP signing and channel binding, configured in the next lesson.

One current change affects how you detect RC4 abuse. Following CVE-2026-20833 (KB5073381), Windows updates from April 2026 change the KDC default so that, for an account with no explicit msDS-SupportedEncryptionTypes attribute, the DC assumes AES only (DefaultDomainSupportedEncTypes defaults to 0x18, AES-SHA1). A DC that already has its own DefaultDomainSupportedEncTypes registry value keeps it, and an administrator can still set the attribute per account to allow RC4. So a detection that looks only for RC4 (0x17) service tickets weakens over time; lesson 04 also counts the distinct service tickets one account requests.

04. Groups, the access token and Group Policy

Authorisation is built from groups and the access token. Permissions are granted to groups, which can be nested, and users inherit them through membership. When you log on, the system gathers every SID you reach through nesting, plus well-known SIDs such as Everyone (S-1-1-0) and Authenticated Users (S-1-5-11), into your access token with your privileges. When a thread touches a securable object, the kernel compares the token's SIDs against the object's access control list.

A few SIDs are worth knowing by sight: RID 512 is Domain Admins, 500 is the built-in Administrator, 502 is krbtgt, whose key protects every TGT, and 525 is Protected Users. Account behaviour is also set in the userAccountControl bitmask. Two flags matter for attacks you will detect: DONT_REQ_PREAUTH (0x400000) disables pre-authentication and exposes the account to AS-REP roasting, and TRUSTED_FOR_DELEGATION (0x80000) lets a service impersonate users to other services (unconstrained delegation).

Group Policy (GPO) pushes settings to computers and users. Each machine applies policy in a fixed order: local policy first, then policies linked to the site, the domain and finally each organisational unit (OU) from the top down. The setting applied last wins, unless a higher policy is Enforced. This order is why a domain-wide hardening policy can be undone by a careless OU-level policy, and why editing a GPO (ATT&CK T1484.001) lets an attacker push settings to many machines at once.

The Python model below expands nested groups, including a loop of the kind old domains collect, and decodes the account flags and encryption types.

Python · token_view.py
"""Build simplified access tokens and decode account flags from a tiny directory."""
DOMAIN_SID = "S-1-5-21-1111111111-2222222222-3333333333"

# groups: name -> (RID, memberOf). Every name and SID here is made up.
GROUPS = {
    "Domain Users": (513, []),
    "Domain Admins": (512, []),
    "Protected Users": (525, []),
    "Helpdesk": (1201, ["Workstation-Admins"]),
    "Workstation-Admins": (1202, ["Print-Operators-L"]),
    "Print-Operators-L": (1203, ["Helpdesk"]),      # a loop: old domains have them
}
USERS = {
    "amira": {"rid": 1104, "memberOf": ["Helpdesk"], "uac": 0x200},
    "svc-sql": {"rid": 1110, "memberOf": [], "uac": 0x10200,
                "spn": "MSSQLSvc/sql01.lab.example.invalid:1433", "enctypes": None},
    "legacy-scan": {"rid": 1111, "memberOf": [], "uac": 0x410200, "enctypes": 0x4},
    "da-omar": {"rid": 1120, "memberOf": ["Domain Admins", "Protected Users"],
                "uac": 0x100200, "enctypes": 0x18},
}
WELL_KNOWN = {"S-1-1-0": "Everyone", "S-1-5-11": "Authenticated Users"}

UAC_FLAGS = {0x2: "ACCOUNTDISABLE", 0x20: "PASSWD_NOTREQD", 0x200: "NORMAL_ACCOUNT",
             0x10000: "DONT_EXPIRE_PASSWORD", 0x80000: "TRUSTED_FOR_DELEGATION",
             0x100000: "NOT_DELEGATED", 0x400000: "DONT_REQ_PREAUTH"}
ENC_BITS = {0x1: "DES-CBC-CRC", 0x2: "DES-CBC-MD5", 0x4: "RC4", 0x8: "AES128",
            0x10: "AES256", 0x20: "AES-SK"}


def sid(rid):
    return f"{DOMAIN_SID}-{rid}"


def expand(groups):
    """Return every group reached through memberOf, following nesting once."""
    seen, todo = [], list(groups)
    while todo:
        g = todo.pop(0)
        if g in seen:
            continue                     # the loop above would otherwise never end
        seen.append(g)
        todo.extend(GROUPS[g][1])
    return seen


def token(user):
    u = USERS[user]
    names = ["Domain Users"] + expand(u["memberOf"])   # primary group comes first
    lines = [f"  {sid(u['rid']):<47} user {user}"]
    lines += [f"  {sid(GROUPS[g][0]):<47} {g}" for g in names]
    lines += [f"  {s:<47} {n}" for s, n in WELL_KNOWN.items()]
    return lines


def flags(value, table):
    return [name for bit, name in table.items() if value & bit] or ["(none)"]


for user in ("amira", "da-omar"):
    print(f"token for {user}:")
    print("\n".join(token(user)))
print()
for user, u in USERS.items():
    enc = u.get("enctypes")
    enc_text = "not set"
    if enc is not None:
        enc_text = f"{enc:#x} " + "+".join(flags(enc, ENC_BITS))
    print(f"{user:<12} uac={u['uac']:#09x} {','.join(flags(u['uac'], UAC_FLAGS))}")
    print(f"{'':<12} msDS-SupportedEncryptionTypes={enc_text}")
    if "spn" in u:
        print(f"{'':<12} SPN={u['spn']}")
Terminal
python3 token_view.py
Expected output
token for amira:
  S-1-5-21-1111111111-2222222222-3333333333-1104  user amira
  S-1-5-21-1111111111-2222222222-3333333333-513   Domain Users
  S-1-5-21-1111111111-2222222222-3333333333-1201  Helpdesk
  S-1-5-21-1111111111-2222222222-3333333333-1202  Workstation-Admins
  S-1-5-21-1111111111-2222222222-3333333333-1203  Print-Operators-L
  S-1-1-0                                         Everyone
  S-1-5-11                                        Authenticated Users
token for da-omar:
  S-1-5-21-1111111111-2222222222-3333333333-1120  user da-omar
  S-1-5-21-1111111111-2222222222-3333333333-513   Domain Users
  S-1-5-21-1111111111-2222222222-3333333333-512   Domain Admins
  S-1-5-21-1111111111-2222222222-3333333333-525   Protected Users
  S-1-1-0                                         Everyone
  S-1-5-11                                        Authenticated Users

amira        uac=0x0000200 NORMAL_ACCOUNT
             msDS-SupportedEncryptionTypes=not set
svc-sql      uac=0x0010200 NORMAL_ACCOUNT,DONT_EXPIRE_PASSWORD
             msDS-SupportedEncryptionTypes=not set
             SPN=MSSQLSvc/sql01.lab.example.invalid:1433
legacy-scan  uac=0x0410200 NORMAL_ACCOUNT,DONT_EXPIRE_PASSWORD,DONT_REQ_PREAUTH
             msDS-SupportedEncryptionTypes=0x4 RC4
da-omar      uac=0x0100200 NORMAL_ACCOUNT,NOT_DELEGATED
             msDS-SupportedEncryptionTypes=0x18 AES128+AES256

Read the output as a defender. amira is an ordinary user, but through Helpdesk she reaches Workstation-Admins and Print-Operators-L; the expansion does not hang on the loop because the script skips groups it has already seen. Over-nested groups hide real privilege this way. The flag decode marks two risky accounts. legacy-scan has DONT_REQ_PREAUTH, so the KDC answers a TGT request for it without proof of the password. Part of that reply (the AS-REP) is encrypted with a key derived from the account's password, so whoever receives it can test password guesses offline, with no failed logons on the DC. Its RC4 pin makes the guessing cheaper. svc-sql has an SPN and no explicit encryption types, so after the April 2026 change the DC assumes AES for it, and an RC4-only Kerberoasting rule would miss a request for its ticket.

05. Hybrid identity with Microsoft Entra Connect

Most organisations extend AD to Microsoft Entra ID, Microsoft's cloud directory. The bridge is Microsoft Entra Connect (or the lighter Entra Cloud Sync agent), which synchronises accounts to the cloud. The cloud can validate a password in three ways, each putting the trust in a different place.

  • Password hash synchronisation (PHS) is the simplest. Every two minutes a sync agent reads a non-reversible form of each account's password hash from a DC over the replication protocol, hashes it again and stores that in Entra ID. Sign-in is checked in the cloud, so it works even if the DC is down; the original hash is not sent.
  • Pass-through authentication (PTA) installs a lightweight on-premises agent that validates each password against AD in real time over outbound connections only. The cloud never stores the password, but sign-in depends on the agent and a reachable DC.
  • Federation hands authentication to a separate trusted system such as AD FS, which validates the password and returns a token.

Two facts about PHS matter for defence. First, the sync agent needs the Replicate Directory Changes and Replicate Directory Changes All rights to read the hashes, the same rights a DCSync attack abuses. So the sync account (with express settings, its name starts with MSOL_) legitimately holds them, and your DCSync detection must allow-list that exact account, not every name with the prefix. Second, because that account reads every password hash, Microsoft treats the Entra Connect server as a Tier 0 (Control Plane) asset: protect it and its MSOL_ account as carefully as a DC.

06. Check your understanding

Practice check · 3 questions

How identity is decided

Three questions about Kerberos, tokens and hybrid identity.

Q1. After the AS exchange, the client holds a TGT it will present for later service tickets. Which key is the TGT encrypted with, and what follows from that?
Q2. A domain-wide GPO sets a value one way, and a GPO linked to the workstation's OU sets it the other way, with no Enforced flag. Which value does the workstation end up with?
Q3. Why does the Entra Connect password hash sync account (MSOL_...) legitimately hold directory replication rights, and what must your DCSync detection do about it?
Practice only: not graded, not saved, not evidence.

07. Apply it

In your isolated lab (one DC, one member server, one workstation from evaluation images), connect the model to reality:

  • On the DC, create one test user with an SPN and one with pre-authentication disabled, and read their userAccountControl and msDS-SupportedEncryptionTypes with Get-ADUser -Properties. Compare the values with the flags the Python model decodes.
  • Sign in on the workstation and run whoami /groups and klist. Match the group SIDs to a token the model builds, and note which tickets use AES (0x12) not RC4 (0x17).
  • Write two sentences on where the trust sits for PHS, PTA and federation, and which component is Tier 0 in each.

08. Review prompt

Without looking back, explain: the AS and TGS exchanges and what a TGT and service ticket contain; what the PAC carries and why a service trusts it; one situation that forces NTLM; how nested groups reach a token; and how PHS, PTA and federation differ in where the password is checked and which asset is Tier 0.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check