SyntaxPilot
Courses/Cybersecurity Fundamentals/Lesson 34
Video coming soonThis lesson’s video is being made

Start with the notes below; the video appears here as soon as it is on YouTube.

Cybersecurity Fundamentals · Lesson 34 of 90

Enterprise identity: IAM lifecycle, PAM and directories

identity and access management (IAM)joiner-mover-leaverprovisioning and deprovisioningaccess reviews and recertificationprivileged access management (PAM)privileged accountsjust-in-time (JIT) accessbreak-glass accountsservice accountsdirectory servicesLDAPActive DirectoryEntra IDKerberos (tickets, KDC, TGT)

These are the notes for Cybersecurity Fundamentals (defensive), episode 34. Episode 33 gave every app one login through single sign-on. Today we zoom out to a whole company: thousands of people joining, changing teams and leaving, plus administrators with enormous powers. We watch access quietly pile up and invent the fixes one by one: identity and access management (IAM), the joiner-mover-leaver lifecycle, provisioning and deprovisioning, access reviews and recertification, privileged access management (PAM), just-in-time (JIT) access, break-glass accounts, service accounts, directory services, LDAP, Active Directory, group policy, Microsoft Entra ID, Kerberos (the KDC, the TGT and service tickets) and the legacy NTLM. Every term is explained the first time it appears, and the Glossary at the end defines them all again.

Meera, Arjun, Kabir, Priya, ChaiCart and every name, key and ID here are made up, and everything runs locally on toy data. Every code sample runs with Python 3 (standard library only); outputs are real, copied from actual runs. The Kerberos demo is a toy model of the idea: real Kerberos encrypts tickets, the toy only seals them with an HMAC.

The problems you'll solve

Problem Idea it teaches
Someone changes team and keeps their old access Privilege creep; IAM; joiner-mover-leaver
One-off grants that never go away Access reviews, recertification, end dates
Admin rights switched on all day, every day Privileged accounts, PAM, vaults, session recording, JIT access
The login system itself is down Break-glass accounts
Programs that log in with no human Service accounts
Where do 5,000 identities live? Directory services, LDAP, Active Directory, group policy, Entra ID
Fifty servers, and each one wants your password Kerberos: KDC, TGT, service tickets
The older Windows login NTLM and why it is deprecated

Problem 1: access piles up

ChaiCart is a made-up tea delivery company with 5,000 staff, 40 apps and 300 access groups. A group is a named bundle of permissions, for example finance-payments (may approve payments). Giving someone access usually means adding them to a group.

Meera joins Finance and gets finance-payments and finance-reports. A year later she moves to Marketing. IT does the obvious thing: it adds the marketing groups she needs.

Demo 1: the obvious "just add the new access"

# The obvious way: when someone changes team, just ADD the new team's access
access = {"meera": {"finance-payments", "finance-reports"}}

def move(user, new_groups):                     # HR: "Meera moved to Marketing"
    access[user] |= new_groups                  # add marketing ... remove nothing

move("meera", {"marketing-cms", "marketing-ads"})
print("Meera now has:")
for group in sorted(access["meera"]): print("   ", group)
print("Can Meera approve payments?", "finance-payments" in access["meera"])

Output:

Meera now has:
    finance-payments
    finance-reports
    marketing-ads
    marketing-cms
Can Meera approve payments? True

A designer in Marketing can still approve payments. Why? Access was only ever added, never taken away. This slow pile-up is called privilege creep (or access creep): every team change leaves old rights behind, and after a few years a long-time employee can reach almost everything. If that account is phished (episode 6), the attacker inherits all of it. It also breaks least privilege (episode 3): people should have only the access their current job needs.

Identity and access management (IAM) and the joiner-mover-leaver lifecycle

Identity and access management (IAM) is the discipline of making sure the right identities have the right access, to the right things, at the right time, for the right reasons, and nothing more. An identity is one person or program the company knows about (an employee, a contractor, a backup job).

Real-life example: a hostel warden's key register.

In a hostel In a company Name
A new student gets a room key and a mess card on day one Accounts and groups are created for the new employee's role Joiner → provisioning
A student changes rooms: the old key comes back before the new key is given Access is recomputed from the new role; old access is removed Mover
A student leaves: every key is returned and ticked off in the register Every account and group is removed the same day Leaver → deprovisioning
  • Provisioning = creating accounts and granting access. Deprovisioning = disabling or deleting accounts and removing access.
  • The HR system (human resources) is usually the source of truth: it knows first when someone joins, moves or leaves. The IAM system turns those HR events into changes in every app, often using SCIM (episode 33).
  • The role decides the access. Everyone in a role gets the same starting set, often called birthright access (for example email and the team's apps). This is role-based access control, RBAC, from episode 30.
  • Movers are the most forgotten case. A mover's access must be replaced from the new role, never just added to.

Demo 2: access from the role

# The fix: access comes FROM the role. Joiner, mover, leaver all recompute it.
ROLE_ACCESS = {"finance":   {"finance-payments", "finance-reports", "email"},
               "marketing": {"marketing-cms", "marketing-ads", "email"}}
people, access = {}, {}

def lifecycle(event, user, role=None):
    if event in ("joiner", "mover"):
        people[user] = role
        access[user] = set(ROLE_ACCESS[role])   # replace, never just add
    if event == "leaver":
        people.pop(user); access.pop(user)      # every account, the same day
    return f"{event:6} {user}: {sorted(access.get(user, []))}"

print(lifecycle("joiner", "meera", "finance"))
print(lifecycle("mover",  "meera", "marketing"))
print(lifecycle("leaver", "meera"))

Output:

joiner meera: ['email', 'finance-payments', 'finance-reports']
mover  meera: ['email', 'marketing-ads', 'marketing-cms']
leaver meera: []

As a mover, Meera has only marketing access, and the payment rights are gone. As a leaver she has nothing.

Problem 2: exceptions linger, so review access

Arjun in Marketing asks for finance-payments "just for one project", and his manager approves. That group isn't part of his role, so it's an exception. The project ends; nobody remembers the grant, and the lifecycle code never touches it because no HR event happened.

The fix is a regular check, an access review: every quarter (or every month for sensitive systems), each manager or system owner sees what their people can access and must confirm or revoke each item. Confirming access again is called recertification (or attestation). Many regulations and audits require it.

Demo 3: a toy access review

# Access review: every quarter, each manager re-approves (recertifies) what each person has
ROLE_ACCESS = {"marketing": {"marketing-cms", "marketing-ads", "email"}}
grants = [  # (user, role, group, days since last used)
    ("arjun", "marketing", "marketing-cms",    2),
    ("arjun", "marketing", "email",            0),
    ("arjun", "marketing", "finance-payments", 210),   # granted "just for one project"
    ("arjun", "marketing", "marketing-ads",    130)]

for user, role, group, idle in grants:
    if group not in ROLE_ACCESS[role]: verdict = "REVOKE: not part of the role"
    elif idle > 90:                    verdict = "ASK MANAGER: unused for 90+ days"
    else:                              verdict = "keep"
    print(f"{user:6} {group:17} idle {idle:3}d -> {verdict}")

Output:

arjun  marketing-cms     idle   2d -> keep
arjun  email             idle   0d -> keep
arjun  finance-payments  idle 210d -> REVOKE: not part of the role
arjun  marketing-ads     idle 130d -> ASK MANAGER: unused for 90+ days

What makes reviews work in real life:

  • Show usage data (when was this last used?) so reviewers aren't guessing.
  • Flag the risky items first (outside the role, unused, privileged) and keep the list short. A reviewer facing 400 rows clicks "approve all": that's called rubber-stamping.
  • Give exceptions an end date when they are granted, so they expire even if nobody remembers.
  • Revoke automatically when a reviewer doesn't answer by the deadline, for high-risk access.

Problem 3: privileged access

Kabir is a database administrator. His account has full rights over every database all day, every day, even while he reads email. Rights that are always switched on are called standing privilege. One convincing phishing email, and an attacker takes over his session: now the attacker is an administrator over every database. In the kill chain of episode 4, attackers hunt for exactly these accounts.

A privileged account is one that can change systems, not just use them: a database admin, a domain admin in Windows, root on Linux (episode 9), a cloud administrator. Privileged access management (PAM) is the set of tools and rules that guard them:

PAM control What it does Why
Separate admin account Kabir has kabir for email and adm-kabir for admin work A phishing click lands on the normal account
Password vault The PAM tool stores admin passwords, hands them out on request, and changes (rotates) them after use Nobody knows the password long-term; nothing to reuse
Session recording and logging Every admin session is logged, often recorded like CCTV A trail for investigations; deters misuse
Approval A second person approves admin access Separation of duties (episode 3)
Just-in-time (JIT) access Nobody is an admin by default; rights are granted for a short time and expire on their own No standing privilege for an attacker to steal
Privileged access workstation (PAW) A locked-down computer used only for admin work Malware on a normal laptop can't reach admin sessions

Demo 4: just-in-time admin access

# PAM, just-in-time (JIT): no standing admin. Ask, get approved, power expires by itself.
grants = {}                                     # user -> time the admin right expires

def request_admin(user, reason, approver, minutes):
    if approver == user: return "DENIED: you can't approve your own request"
    grants[user] = now + minutes * 60
    return f"granted to {user} for {minutes} min ({reason}), approved by {approver}"

def is_admin(user, at):
    return grants.get(user, 0) > at

now = 1_800_000_000                             # a fixed clock, so the demo is repeatable
print(request_admin("kabir", "patch the DB server", "kabir", 60))
print(request_admin("kabir", "patch the DB server", "priya", 60))
print("admin now?        ", is_admin("kabir", now))
print("admin 59 min later?", is_admin("kabir", now + 59 * 60))
print("admin 61 min later?", is_admin("kabir", now + 61 * 60))

Output:

DENIED: you can't approve your own request
granted to kabir for 60 min (patch the DB server), approved by priya
admin now?         True
admin 59 min later? True
admin 61 min later? False

Self-approval is refused (separation of duties), and the approved grant expires after 60 minutes without anybody having to remember to remove it. If Kabir is phished tomorrow, the attacker finds a normal account with no admin rights waiting in it: the window of risk shrinks from all year to one hour. Some systems go further with just-enough access (JEA): only the specific admin commands the task needs.

Break-glass accounts

What if the identity provider or MFA service itself is down, and nobody can log in to fix it? Companies keep break-glass accounts (named after "break glass in case of emergency"): emergency admin accounts that don't depend on SSO.

  • Usually two of them, so one mistake doesn't lock everyone out.
  • Long, random secrets (or hardware keys) kept in a sealed physical safe or split between people.
  • Any use raises an alarm, and every use is reviewed afterwards.
  • Tested regularly, so they actually work on the bad day.

Service accounts

Not every identity is a person. A service account is the identity a program uses, for example the nightly backup job that logs in to the database. Nobody types its password, so normal MFA doesn't fit, which makes forgotten service accounts a favourite target. Good practice:

  • Least privilege: only what that one program needs.
  • A named human owner, so someone answers for it.
  • Long random secrets, rotated automatically (or managed identities / workload identities in the cloud, which have no password at all).
  • No interactive login (it can't be used to sign in to a desktop).
  • Watch it: alert if it logs in from somewhere new or at odd times.

Problem 4: where do 5,000 identities live? Directory services

Real-life example: a school's master register: one book listing every student, class and teacher, organised as school → class 9 → section B, with a standard way to ask "who is in 9B?".

A directory service is that register for a company: one database of every user, group and computer, which every app can ask. It is organised as a tree:

Part Short for Meaning Example
dc domain component One part of the company's domain name dc=chaicart,dc=example
ou organisational unit A folder in the tree, often a team or a kind of object ou=marketing
cn common name The entry's own name cn=meera
DN distinguished name The full path of an entry, read right to left cn=meera,ou=marketing,dc=chaicart,dc=example
attribute A field on the entry mail, title

LDAP, the Lightweight Directory Access Protocol, is the standard way for apps to search and read a directory. Its current specification is RFC 4511 (June 2006). A search names a base (the branch to start from) and a filter, written in brackets, for example (title=Admin) or (&(objectClass=person)(ou=marketing)).

# A directory: one tree of every person, group and computer. Toy LDAP-style search.
directory = {
  "cn=meera,ou=marketing,dc=chaicart,dc=example": {"mail": "meera@chaicart.example", "title": "Designer"},
  "cn=arjun,ou=marketing,dc=chaicart,dc=example": {"mail": "arjun@chaicart.example", "title": "Analyst"},
  "cn=priya,ou=it,dc=chaicart,dc=example":        {"mail": "priya@chaicart.example", "title": "Admin"},
  "cn=laptop-17,ou=computers,dc=chaicart,dc=example": {"os": "Windows 11"}}

def search(base, attr=None, value=None):        # base = which branch of the tree to look in
    for dn, entry in directory.items():
        if dn.endswith(base) and (attr is None or entry.get(attr) == value):
            yield dn, entry

print("Everyone in marketing:")
for dn, e in search("ou=marketing,dc=chaicart,dc=example"):
    print("  ", dn, "|", e["mail"])
print("Who is an Admin?", [dn for dn, e in search("dc=chaicart,dc=example", "title", "Admin")])

Output:

Everyone in marketing:
   cn=meera,ou=marketing,dc=chaicart,dc=example | meera@chaicart.example
   cn=arjun,ou=marketing,dc=chaicart,dc=example | arjun@chaicart.example
Who is an Admin? ['cn=priya,ou=it,dc=chaicart,dc=example']

Every app that asks the directory (the VPN, the wiki, a printer) checks the same source of truth: remove Meera's entry once, and every app that asks sees she's gone. Two safety notes: apps should connect over LDAPS or StartTLS (LDAP inside TLS, episode 22), never send passwords in cleartext; and building filters by pasting user input into strings causes LDAP injection (episode 39).

Active Directory, group policy and Microsoft Entra ID

  • Active Directory (AD) is Microsoft's directory for Windows networks. Its servers are domain controllers (DCs), which hold every user, group and computer in the Windows domain (the company's managed network of Windows machines and accounts). AD answers lookups over LDAP and handles logins with Kerberos.
  • Group policy (group policy objects, GPOs): settings an admin writes once in AD and pushes to every computer or user in a branch of the tree, for example "lock the screen after 10 minutes", "block USB storage", "turn on the firewall". It's a powerful hardening tool (episode 9) and a powerful attacker target.
  • Microsoft Entra ID is Microsoft's cloud identity service: SSO and MFA for cloud apps such as Microsoft 365. It was called Azure Active Directory (Azure AD) until Microsoft announced the rename on 11 July 2023. It speaks modern protocols (OIDC, SAML, OAuth) rather than LDAP and Kerberos. Many companies run both, syncing accounts from on-premises AD up to Entra ID.

Problem 5: fifty servers, one password. Kerberos

Meera uses fifty servers a day (file shares, printers, mail, the wiki). The obvious way: each server asks for her password and checks it with the directory. But then every server sees her password: hack one forgotten print server and it quietly collects the password of everyone who prints. We need to prove who we are to a server without ever giving it the password.

Real-life example: a fair.

At a fair Kerberos What it is
Show your ID once at the gate, get a wristband for today TGT, ticket-granting ticket Proof that you logged in this morning, from the KDC
Show the wristband, get a token for one ride Service ticket A pass for ONE server, sealed with that server's own key
The ticket office that issues both KDC, key distribution centre In Active Directory, the domain controllers

The flow, step by step:

  1. Log in once. Meera's computer proves she knows her password to the KDC (the password itself isn't sent; a key derived from it is used). The KDC returns a TGT, sealed with the KDC's own secret key (the krbtgt account's key).
  2. Ask for a service ticket. When she opens the file server, her computer shows the TGT to the KDC and asks for a ticket for that server. The KDC returns a service ticket sealed with the file server's key.
  3. Use the ticket. The file server opens the ticket with its own key and learns "this is Meera". It never sees her password.
  4. Tickets expire: in a Windows domain the default maximum lifetime of a user's TGT is 10 hours, so a stolen ticket is only useful for a while.

Kerberos version 5 is specified in RFC 4120 (July 2005).

Demo 6: a toy Kerberos

# Kerberos idea in a toy: the KDC hands out tickets; the password never travels to a server.
import hmac, hashlib, json
KEYS = {"krbtgt": b"kdc-secret-key", "fileserver": b"files-secret-key"}  # only the KDC knows all keys

def seal(key, data):                            # stand-in for encryption: an HMAC seal
    body = json.dumps(data, sort_keys=True)
    return body, hmac.new(KEYS[key], body.encode(), hashlib.sha256).hexdigest()

def opened(key, ticket):
    body, tag = ticket
    ok = hmac.compare_digest(tag, hmac.new(KEYS[key], body.encode(), hashlib.sha256).hexdigest())
    return json.loads(body) if ok else None

tgt = seal("krbtgt", {"user": "meera", "expires": 10})              # 1. login once -> TGT
st = seal("fileserver", {"user": opened("krbtgt", tgt)["user"], "expires": 10})  # 2. TGT -> service ticket
print("file server reads:", opened("fileserver", st))                # 3. the server checks the seal
forged = (st[0].replace("meera", "priya"), st[1])                    # someone edits the name
print("forged ticket:   ", opened("fileserver", forged))

Output:

file server reads: {'expires': 10, 'user': 'meera'}
forged ticket:    None

The genuine ticket opens and says Meera; the edited one opens to None (rejected) because the seal no longer matches. hmac.compare_digest is the constant-time comparison from episode 27.

Protecting Kerberos

  • The krbtgt key seals every TGT. Whoever steals it can create TGTs for anyone (often called a golden ticket), so domain controllers are tier 0: guarded more than any other system, administered only from privileged access workstations.
  • Service tickets are sealed with the service account's key, which comes from its password. A weak service account password makes tickets that can be guessed offline (Kerberoasting, concept): use long, random service account passwords or managed service accounts.
  • Clocks must agree: tickets carry times, so Kerberos rejects machines whose clocks are too far off.
  • Monitor ticket requests on domain controllers for unusual patterns.

NTLM, the legacy fallback

Before Kerberos, Windows used NTLM (NT LAN Manager), a challenge-response login: the server sends a random challenge, and the client answers with a value computed from the password hash. Its weaknesses: the client never proves the server is genuine, and the answer can be relayed by a man in the middle (episode 10) to another server (NTLM relay, concept).

In June 2024, Microsoft deprecated all versions of NTLM (LANMAN, NTLMv1, NTLMv2): they are no longer under active feature development. Apps should call Negotiate, which tries Kerberos first and falls back to NTLM only when needed. Defenders turn on NTLM auditing, find what still uses it, and switch it off piece by piece.

The next problem

Identities now have a lifecycle, exceptions get reviewed, admins are just in time, and servers never see passwords. But many networks still have one dangerous habit: if your laptop is inside the office network, lots of things simply trust it. One infected laptop inside, and that trust belongs to the attacker. The fix is an architecture: never trust, always verify. That's zero trust, episode 35.

The whole chain

Step Problem Invention
1 A mover kept old access IAM; joiner-mover-leaver; access from the role
2 One-off grants linger Access reviews, recertification, end dates
3 Always-on admins PAM: separate admin accounts, vault, recording, JIT access
4 SSO is down; programs log in Break-glass accounts; service accounts
5 5,000 identities, 40 apps Directory service, LDAP, Active Directory, group policy, Entra ID
6 Passwords sent to every server Kerberos: KDC, TGT, service tickets; NTLM is legacy

Common mistakes (and what they print)

Mistake What you see Why it's wrong Fix
Mover: add new access, keep the old Can Meera approve payments? True Privilege creep Recompute access from the new role
Exceptions with no end date finance-payments idle 210d -> REVOKE: not part of the role (found months late) Nobody remembers them End date at grant time + quarterly reviews
Rubber-stamp reviews Every row approved in 30 seconds Reviewers can't judge 400 rows Usage data, risky items first, short lists
Standing admin rights A phished admin = an attacker admin Always-on power JIT access; separate admin account
Approving your own request DENIED: you can't approve your own request (this is the fix working) No second pair of eyes Separation of duties
Leaver handled in HR only The ex-employee's VPN still works Apps never heard Automated deprovisioning (SCIM), review leavers
Forgotten service account with an old password Weak tickets; unexplained logins No owner, no rotation Owner, rotation, least privilege, monitoring
Plain LDAP on port 389 with passwords Passwords readable on the network No encryption LDAPS or StartTLS
Leaving NTLM on everywhere NTLM logins in the DC logs Relay risk, legacy Audit, then move to Kerberos via Negotiate

Mini project: ChaiCart's tiny IAM

Roles decide access, exceptions get an approver and an end date, a review removes expired exceptions, and a leaver loses everything. Every change is logged.

# Mini project: ChaiCart's tiny IAM. Roles, exceptions with end dates, reviews, leavers.
ROLE_ACCESS = {"finance":   {"finance-payments", "finance-reports", "email"},
               "marketing": {"marketing-cms", "marketing-ads", "email"}}
role, exceptions, log = {}, {}, []     # exceptions: user -> {group: end_day}

def event(kind, user, new_role=None, day=0):
    if kind in ("joiner", "mover"):
        role[user] = new_role; exceptions.setdefault(user, {})
    if kind == "leaver":
        role.pop(user); exceptions.pop(user, None)
    log.append(f"day {day}: {kind} {user} {new_role or ''}".strip())

def grant_exception(user, group, approver, end_day):
    if approver == user: return "DENIED: self-approval"
    exceptions[user][group] = end_day; return f"exception {group} for {user} until day {end_day}"

def access(user, day):                          # effective access = role + live exceptions
    if user not in role: return set()
    live = {g for g, end in exceptions[user].items() if end > day}
    return ROLE_ACCESS[role[user]] | live

def review(day):                                # quarterly: drop expired exceptions
    for user, ex in exceptions.items():
        for g in [g for g, end in ex.items() if end <= day]:
            del ex[g]; log.append(f"day {day}: review revoked {g} from {user}")

event("joiner", "meera", "finance", day=1)
event("mover",  "meera", "marketing", day=200)
print("day 200 Meera:", sorted(access("meera", 200)))
print(grant_exception("meera", "finance-reports", "arjun", 260))
print("day 250 Meera:", sorted(access("meera", 250)))
review(270)
print("day 270 Meera:", sorted(access("meera", 270)))
event("leaver", "meera", day=300)
print("day 300 Meera:", sorted(access("meera", 300)))
print("\n".join(log))

Output:

day 200 Meera: ['email', 'marketing-ads', 'marketing-cms']
exception finance-reports for meera until day 260
day 250 Meera: ['email', 'finance-reports', 'marketing-ads', 'marketing-cms']
day 270 Meera: ['email', 'marketing-ads', 'marketing-cms']
day 300 Meera: []
day 1: joiner meera finance
day 200: mover meera marketing
day 270: review revoked finance-reports from meera
day 300: leaver meera

Ideas to extend it: add a JIT admin grant with a 4-hour maximum, make review also flag role access unused for 90 days, and refuse an exception whose approver isn't the user's manager.

Practice

1. End dates for exceptions. Change Demo 3 so each exception carries the day it ends, and the review revokes it automatically once that day has passed.

Solution
# Practice 1: every exception gets an end date; the review revokes expired ones automatically
ROLE_ACCESS = {"marketing": {"marketing-cms", "marketing-ads", "email"}}
today = 400                                     # day number, a fixed clock for the demo
grants = [  # (user, role, group, days since last used, ends on day)
    ("arjun", "marketing", "marketing-cms",    2,   None),   # role access: no end date
    ("arjun", "marketing", "finance-payments", 210, 190),    # project exception, ended day 190
    ("arjun", "marketing", "finance-reports",  3,   430)]    # exception, still running

for user, role, group, idle, ends in grants:
    if group not in ROLE_ACCESS[role] and (ends is None or ends <= today):
        verdict = "REVOKE: exception expired"
    elif group not in ROLE_ACCESS[role]:
        verdict = f"keep until day {ends}"
    elif idle > 90: verdict = "ASK MANAGER: unused for 90+ days"
    else:           verdict = "keep"
    print(f"{group:17} -> {verdict}")
marketing-cms     -> keep
finance-payments  -> REVOKE: exception expired
finance-reports   -> keep until day 430

2. A maximum grant time. Change Demo 4 so no JIT grant can be longer than 4 hours.

Solution
# Practice 2: just-in-time admin with a hard maximum of 4 hours
MAX_MINUTES = 240
grants = {}
now = 1_800_000_000

def request_admin(user, approver, minutes):
    if approver == user:      return "DENIED: you can't approve your own request"
    if minutes > MAX_MINUTES: return f"DENIED: {minutes} min is over the {MAX_MINUTES} min maximum"
    grants[user] = now + minutes * 60
    return f"granted to {user} for {minutes} min"

print(request_admin("kabir", "priya", 600))
print(request_admin("kabir", "priya", 120))
DENIED: 600 min is over the 240 min maximum
granted to kabir for 120 min

3. Ticket expiry. Make the file server in Demo 6 reject a ticket whose expires time has passed.

Solution
# Practice 3: tickets carry an expiry; the server rejects old ones
import hmac, hashlib, json
KEYS = {"fileserver": b"files-secret-key"}

def seal(key, data):
    body = json.dumps(data, sort_keys=True)
    return body, hmac.new(KEYS[key], body.encode(), hashlib.sha256).hexdigest()

def accept(key, ticket, now):
    body, tag = ticket
    if not hmac.compare_digest(tag, hmac.new(KEYS[key], body.encode(), hashlib.sha256).hexdigest()):
        return "REJECT: bad seal"
    data = json.loads(body)
    if now >= data["expires"]: return "REJECT: ticket expired"
    return f"OK: {data['user']}"

st = seal("fileserver", {"user": "meera", "expires": 10})   # valid until hour 10
print("hour 9: ", accept("fileserver", st, 9))
print("hour 11:", accept("fileserver", st, 11))
hour 9:  OK: meera
hour 11: REJECT: ticket expired

4. A complete leaver. A leaver must lose role access, exceptions and any JIT admin grant. Write leaver(user) that removes all three and proves nothing is left.

Solution
# Practice 4: a leaver must also lose exceptions and JIT grants, not just role access
access     = {"arjun": {"marketing-cms", "email"}}
exceptions = {"arjun": {"finance-reports"}}
jit_admin  = {"arjun": 1_800_003_600}

def leaver(user):
    removed = sorted(access.pop(user, set()) | exceptions.pop(user, set()))
    if jit_admin.pop(user, None): removed.append("JIT admin grant")
    return removed

print("removed:", leaver("arjun"))
print("anything left?", any(user == "arjun" for d in (access, exceptions, jit_admin) for user in d))
removed: ['email', 'finance-reports', 'marketing-cms', 'JIT admin grant']
anything left? False

5. Think it through. The identity provider is down during a production outage. Who can log in, how, and what happens afterwards?

Answer

One of the two break-glass accounts, whose secret is taken from the sealed safe (often needing two people). Its use raises an alarm. Afterwards the use is reviewed, the secret is changed, and the safe is resealed.

Quick quiz

Arjun got finance-payments "for one project". The project ended seven months ago. His role never changed, so no HR event fired. Which control is designed to catch it? A Kerberos, B a break-glass account, C an access review, D group policy.

Answer

C, an access review. No joiner, mover or leaver event happened, so lifecycle automation never touched the grant. A periodic review (recertification) shows the manager every grant, flags ones outside the role or unused, and revokes them. Better still, the grant should have had an end date.

Interview questions

  1. What is the joiner-mover-leaver process, and which stage is most often handled badly? Joiners get birthright access for their role; movers get access recomputed from the new role; leavers are deprovisioned everywhere the same day. Movers are most often mishandled, causing privilege creep.
  2. What is privilege creep and how do you prevent it? The slow build-up of access as people change roles and receive exceptions. Prevent it with role-based access, replacing (not adding) on move, end dates on exceptions and regular access reviews.
  3. What is an access review, and how do you stop it becoming a rubber stamp? A periodic recertification of who has what. Show usage data, highlight risky items first, keep lists short, and auto-revoke unanswered high-risk items.
  4. What does PAM add on top of normal IAM? Separate admin accounts, password vaulting and rotation, approval, session recording and logging, and just-in-time access, so privileged rights are rare, temporary and watched.
  5. What is just-in-time access and why does it help? Admin rights are granted on request, with approval, for a short time, then expire automatically. A stolen account has no standing privilege.
  6. What is a break-glass account and how should it be protected? An emergency admin account independent of SSO/MFA, for outages. Two accounts, long secrets in a sealed safe, alarms on any use, review and rotation afterwards, regular tests.
  7. Why are service accounts risky? They often have broad rights, no MFA, old passwords and no owner. Give them least privilege, an owner, rotated secrets or managed identities, no interactive login, and monitoring.
  8. What is LDAP, and what is a DN? The protocol for searching and reading a directory (RFC 4511). A distinguished name is an entry's full path in the tree, such as cn=meera,ou=marketing,dc=chaicart,dc=example.
  9. Active Directory vs Entra ID? AD is the on-premises directory for Windows domains (LDAP, Kerberos, group policy). Entra ID (formerly Azure AD) is Microsoft's cloud identity service for SSO and MFA to cloud apps, using OIDC, SAML and OAuth.
  10. Explain Kerberos in three steps. Log in once to the KDC and get a TGT; present the TGT to get a service ticket for one server, sealed with that server's key; the server opens the ticket and learns who you are, never seeing the password.
  11. Why is the krbtgt account so sensitive? Its key seals every TGT; whoever has it can forge TGTs for any user, so domain controllers are tier-0 assets.
  12. Why is NTLM considered legacy? Challenge-response with no server authentication, vulnerable to relay; Microsoft deprecated all versions in 2024. Use Negotiate so Kerberos is preferred, audit remaining NTLM use and remove it.

Glossary

Term Meaning in plain words Example
Identity One person or program the company knows about Meera; the backup job
Group A named bundle of permissions; joining it grants them finance-payments
Identity and access management (IAM) Making sure the right identities have the right access, and nothing more ChaiCart's IAM system
Source of truth The one system whose data everyone else follows The HR system for who works here
Joiner A new person; gets access for their role Meera's first day in Finance
Mover A person changing role; access is recomputed and old access removed Meera moving to Marketing
Leaver A person leaving; all access removed Meera's last day
Joiner-mover-leaver (JML) The three lifecycle events every identity goes through HR events driving IAM
Provisioning Creating accounts and granting access Adding Meera to email
Deprovisioning Disabling accounts and removing access Removing every group on her last day
Birthright access The starting access everyone in a role gets automatically Email + team apps
Privilege creep Access piling up over time as people move and get exceptions A marketer who can approve payments
Exception Access granted outside someone's role finance-payments "for one project"
Access review A periodic check where owners confirm or revoke each person's access The quarterly review in Demo 3
Recertification Confirming again that someone still needs access "Keep" in the review
Rubber-stamping Approving everything in a review without reading "Approve all"
Privileged account An account that can change systems, not just use them Database admin, domain admin, root
Standing privilege Admin rights that are always switched on Kabir's old admin account
Privileged access management (PAM) Tools and rules that guard privileged accounts Vault + approval + recording
Password vault A PAM store that hands out and rotates admin passwords Admin password changed after each use
Session recording Recording an admin session for later review CCTV for admin work
Just-in-time (JIT) access Rights granted on request, for a short time, expiring automatically Admin for 60 minutes
Just-enough access (JEA) Granting only the specific actions a task needs Only "restart service"
Separation of duties Splitting a task so one person can't do it alone You can't approve your own request
Privileged access workstation (PAW) A locked-down computer used only for admin work A separate admin laptop
Break-glass account An emergency admin account that doesn't depend on SSO/MFA Used when the IdP is down
Service account The identity a program uses to log in The nightly backup job
Managed identity A cloud-issued identity for a program, with no password to manage A cloud VM's identity
Directory service One database of every user, group and computer that apps can ask Active Directory
Distinguished name (DN) An entry's full path in the directory tree cn=meera,ou=marketing,dc=chaicart,dc=example
Organisational unit (OU) A folder in the directory tree ou=marketing
LDAP Lightweight Directory Access Protocol: how apps search and read a directory (RFC 4511) (title=Admin)
LDAPS / StartTLS LDAP protected by TLS Port 636, or StartTLS on 389
Active Directory (AD) Microsoft's on-premises directory for Windows domains ChaiCart's domain controllers
Domain controller (DC) A server that runs Active Directory dc01.chaicart.example
Windows domain A company's centrally managed set of Windows machines and accounts CHAICART
Group policy (GPO) Settings pushed from AD to every computer or user in a branch Lock the screen after 10 minutes
Microsoft Entra ID Microsoft's cloud identity service (formerly Azure AD) SSO into Microsoft 365
Kerberos A ticket-based login protocol: servers see tickets, not passwords (RFC 4120) Every Windows domain login
KDC Key distribution centre: the Kerberos server that issues tickets The domain controllers
TGT Ticket-granting ticket: proof you logged in, used to get service tickets Valid 10 hours by default in AD
Service ticket A Kerberos ticket for one server, sealed with that server's key A ticket for the file server
krbtgt The AD account whose key seals every TGT Guarded as tier 0
Tier 0 The most critical systems, whose compromise means compromise of everything Domain controllers, the IdP
NTLM Older Windows challenge-response login, deprecated by Microsoft in 2024 Fallback when Kerberos can't be used
Challenge-response Proving you know a secret by answering a random challenge with it NTLM
Negotiate The Windows mechanism that picks Kerberos first, NTLM only as a fallback What apps should call
NTLM relay (concept) Passing someone's NTLM answer on to another server to log in as them Why NTLM is being removed

Summary

  • IAM keeps the right access with the right identities. Drive it from the HR source of truth through the joiner-mover-leaver lifecycle: provision from the role, replace access on a move, deprovision everything on leaving. Otherwise you get privilege creep.
  • Exceptions get an end date, and access reviews (recertification) with usage data catch what slips through.
  • PAM makes privileged access rare, approved, recorded and temporary: separate admin accounts, a vault, session recording and just-in-time access. Keep break-glass accounts for outages and give every service account an owner, least privilege and rotated secrets.
  • A directory service holds every identity as a tree (DN, OU, CN); apps ask it with LDAP (RFC 4511). Active Directory runs Windows domains with group policy; Microsoft Entra ID (formerly Azure AD) is the cloud side.
  • Kerberos (RFC 4120): log in once to the KDC, get a TGT, trade it for service tickets; servers never see passwords. Guard krbtgt and the domain controllers. NTLM is legacy, deprecated in 2024: prefer Negotiate/Kerberos.

Next episode: zero trust architecture: why being inside the network should prove nothing, NIST SP 800-207, policy engines, device posture, ZTNA vs VPN and BeyondCorp.

Sources: RFC 4511 "Lightweight Directory Access Protocol (LDAP): The Protocol" (IETF, June 2006); RFC 4120 "The Kerberos Network Authentication Service (V5)" (IETF, July 2005); SiliconANGLE, "Azure Active Directory rebrands as Microsoft Entra ID" (13 July 2023, reporting Microsoft's 11 July 2023 announcement); BetaNews, "Microsoft officially deprecates NTLM and promotes Kerberos authentication" (5 June 2024); Microsoft Learn, "Maximum lifetime for user ticket" (default 10 hours). Code outputs from Python 3. Fetched 6 Nov 2026.