IAM Lab in Microsoft Entra ID

I built a complete identity and access management environment from an empty Microsoft Entra ID tenant, for a fictional company I called Mateescu Industries. The goal was to practise identity the way it is actually run and defended, not just administered: design the directory, run the user lifecycle, enforce access controls, govern privilege, and understand how each part is attacked and detected.

The lab was inspired by the four classic IAM failure modes (over-privilege, stale credentials, over-permissive roles, and no change visibility) and applies the Microsoft controls that address them: PIM for standing privilege, a secretless least-privilege app registration for workload identity, and the sign-in and audit logs for visibility. Long-term log export to a SIEM is out of scope here. The lab maps across all four SC-300 (Identity and Access Administrator) domains.

This lab runs in a throwaway tenant with fictional users, so the screenshots below show a disposable environment rather than any production system.

Overview

What I Built

  • Six attribute-driven dynamic department groups
  • Joiner, mover and leaver lifecycle, end to end
  • MFA, Conditional Access and SSPR
  • A tested break-glass emergency-access account
  • PIM, access reviews and entitlement management
  • SAML SSO on an enterprise application
  • A least-privilege workload identity (app registration)
  • End-to-end tests of every governance control, with evidence

Skills Demonstrated

  • RBAC and attribute-based access design
  • Identity lifecycle automation and deprovisioning
  • Zero-trust access controls and MFA strategy
  • Privileged access management and least privilege
  • Identity governance and recertification
  • Attack / detect / harden thinking on each control
  • SC-300 skill set, hands-on

Build, Attack, Detect, Harden

I treated every control the same way: build it correctly, understand how an attacker abuses it, identify the log or event that detects the abuse, and apply the hardening that closes it. That framing runs through all seven phases below, because an IAM engineer is expected to run identity and defend it, not just configure it.

Dynamic Department Groups (RBAC)

I created six security groups (HR, IT, Engineering, Customer Support, Warehouse and Finance) with dynamic membership driven by each user's department attribute. Access follows the attribute: set a user's department and they land in the right group automatically, with no manual membership changes. Every group has an owner and a description stating its purpose, rule and access, and the sensitive groups (HR and Finance) are flagged for priority review.

Design

  • Rule: user.department -eq "<dept>"
  • Group-based access instead of per-user permissions
  • Documented owner and purpose on every group
  • HR and Finance tagged sensitive

Security Angle

  • Abuse: group sprawl and nested groups hide excess access
  • Detect: Entra audit log "Add member to group" events
  • Harden: attribute-driven membership, documented owners, access reviews

Microsoft Entra ID • Dynamic Groups • RBAC • Attribute-Based Access

Six dynamic department security groups in Microsoft Entra ID
Six dynamic department groups, each Security type with attribute-based membership.

Joiner, Mover, Leaver

I ran the full identity lifecycle end to end. A joiner is created with a department and drops into the correct group automatically, inheriting the group's access; licences were assigned in the Microsoft 365 admin center (see Lab vs Production). A mover who changes department is re-scoped in both directions, gaining the new access and losing the old, just by changing one attribute. A leaver is disabled, their sessions revoked, their licences reclaimed, and their department cleared so they drop out of every group.

Leaver Sequence

  • Block sign-in (disable account)
  • Revoke sessions to invalidate refresh tokens
  • Remove licences (reclaim spend)
  • Clear department → drops from dynamic groups
  • Retain, then delete after the retention window

Security Angle

  • Abuse: un-deprovisioned leavers and over-accessed movers are the top identity attack surface
  • Detect: sign-in attempts against disabled accounts; audit-log group changes
  • Harden: revoke tokens on exit (a disable alone leaves sessions live); reclaim access by attribute

Identity Lifecycle • Joiner-Mover-Leaver • Deprovisioning • Token Revocation • Least Privilege

A new user automatically added to their department group
Joiner: a new user lands in their department group automatically via the dynamic rule.
A user moved between departments, re-scoped automatically
Mover: changing the department attribute re-scopes group membership both ways.
A leaver fully deprovisioned: disabled, no groups, no roles, no licences
Leaver: account disabled, zero group memberships, zero roles, zero licences.

MFA, Conditional Access, SSPR & Break-Glass

I hardened authentication and enforced it with Conditional Access. The authentication methods policy allows phishing-resistant passkeys and Microsoft Authenticator, and disables the weak methods (SMS, voice, email OTP). Two Conditional Access policies were deployed in report-only first, then enforced: one requires MFA for all users, the other blocks legacy authentication. SSPR is enabled with two methods and no security questions.

Before enforcing anything, I built a break-glass emergency-access account, excluded it from Conditional Access and the registration campaign, and then tested it: the sign-in log confirmed the policy did not apply to it (“Not matched: Group exclusion”). An untested emergency account is worse than none, because you only discover it fails at the moment you need it.

Controls

  • Passkey (FIDO2) + Authenticator on; SMS / voice / email OTP off
  • CA01: require MFA, all users (break-glass excluded)
  • CA02: block legacy authentication
  • Report-only → reviewed → enforced
  • SSPR: two methods, no security questions, notify on reset

Security Angle

  • Abuse: password spray and legacy-auth bypass defeat password-only sign-in
  • Detect: sign-in logs showing failures across many accounts from one IP; legacy-auth client sign-ins
  • Harden: number-matching MFA, block legacy auth, phishing-resistant methods for admins

MFA • Conditional Access • Passkeys (FIDO2) • SSPR • Break-Glass • Zero Trust

Email OTP, SMS and voice call authentication methods disabled
Weak methods switched off: Email OTP, SMS and voice call.
Conditional Access policies for MFA and blocking legacy authentication
Conditional Access: CA01 (require MFA) and CA02 (block legacy authentication), both On.
Sign-in log showing the MFA policy was not applied to the break-glass account due to group exclusion
Break-glass validated: the MFA policy shows “Not matched: Group exclusion”.

Single Sign-On (SAML)

I configured SAML single sign-on on an enterprise application, assigned access through a department group rather than to individual users, and required assignment so only assigned users reach the app. SSO centralises authentication: one login, with MFA and Conditional Access enforced once, access granted by group, and every sign-in audited.

Configured

  • SAML SSO (Identifier, Reply URL, Sign-on URL)
  • Claims mapping (Name ID = userprincipalname)
  • Group-based app assignment
  • Assignment required

Security Angle

  • Abuse: Golden SAML (forged assertions from a stolen signing key); reply-URL tampering
  • Detect: audit-log changes to SSO config, such as a new reply URL or signing certificate
  • Harden: protect and rotate the signing cert, pin the reply URL, require assignment, enforce MFA

SSO • SAML • Enterprise Applications • Claims Mapping • Group-Based Assignment

SAML single sign-on configured on an enterprise application
SAML SSO configured with claims and an active token-signing certificate.

PIM, Access Reviews & Entitlement Management

This is the governance layer and the hardest SC-300 domain. I first created the problem, a standing Global Administrator assignment on a user who only needed helpdesk-level access, then remediated it with Privileged Identity Management: the standing Global Admin was removed and replaced with an eligible User Administrator role (least privilege plus just-in-time), requiring MFA, a justification, approval and a four-hour activation cap.

I set up a quarterly access review to recertify membership of the break-glass exclusion group (the most dangerous group in the tenant, since anyone in it bypasses MFA) and built an entitlement management access package so users request project access through an approved, time-boxed, auditable workflow instead of being added by hand.

Governance Controls

  • PIM: standing Global Admin → eligible least-privilege role
  • Activation: MFA + justification + approval + 4-hour cap
  • Quarterly access review of the MFA-bypass group
  • Self-service access package with approval and 90-day expiry

Security Angle

  • Abuse: standing admin means one compromise owns the tenant; access creep over time
  • Detect: PIM audit log on every activation; audit-log role changes
  • Harden: no standing privilege, JIT elevation, recurring recertification, fail-closed defaults (except the break-glass group)

PIM • Just-In-Time Access • Access Reviews • Entitlement Management • Least Privilege • Identity Governance

PIM eligible, time-bound User Administrator assignment replacing standing Global Admin
PIM: standing Global Admin replaced with an eligible, time-bound User Administrator role.
Quarterly access review scheduled on the emergency-access group
Quarterly access review recertifying the break-glass exclusion group.
Entitlement management access package for self-service, approved, time-boxed access
Entitlement management: a self-service access package with approval and expiry.

Least-Privilege App Registration

Identity is not only human. I registered an application (a service identity), removed the default delegated permission it did not need, and granted it only a single read-only Microsoft Graph application permission. This is the Microsoft equivalent of an over-permissioned cloud role. An app with excessive Graph permissions can escalate to tenant takeover, so the whole point was least privilege for a non-human identity.

Configured

  • Single-tenant app registration
  • Removed the unused delegated permission
  • Granted only User.Read.All (application, read-only)
  • No client secret (certificate / managed identity preferred)

Security Angle

  • Abuse: over-permissioned apps escalate; leaked secrets give silent persistent access; illicit consent grants
  • Detect: audit log on permission grants, consent events and credential additions
  • Harden: least-privilege Graph scopes, short-lived secrets or managed identities, restrict app registration and consent

Workload Identity • App Registration • Microsoft Graph • Least Privilege • Service Principals

App registration with a single least-privilege Microsoft Graph application permission, admin-consented
Workload identity with one least-privilege Graph permission, admin-consented.

Running the Controls

A control that is configured but never used is a claim, not evidence. So I ran every governance control end to end with the lab's fictional users, acting as admin, requester and approver in separate sessions, and kept the screenshots and logs from each run. Two of the four tests turned up problems in my own configuration.

Tests Run

  • SSO: assigned user signed in with MFA; unassigned user blocked (AADSTS50105)
  • PIM: eligible role requested, approved, used, then deactivated early
  • Access package: user requested project access, approver granted it
  • Access review: wrong member of the MFA-bypass group denied and removed

What Testing Found

  • The break-glass group's review removed access when nobody responded. Changed to "No change"
  • The review recommended Approve for a member who should not be there. It measures sign-in activity, not need
  • The lab admin held an app assignment it did not need. Removed
  • Global Administrator PIM settings are on defaults, with no eligible users. Accepted for the lab

SSO. The SAML Toolkit app requires assignment and is assigned to the Engineering group. An Engineering user signed in through My Apps, with MFA enforced by CA01. An HR user was stopped by Entra before any token was issued. The sign-in log shows both, and also showed the lab admin receiving a token it had no reason to get, which led to removing its assignment.

AADSTS50105 error: unassigned user blocked from the SAML application
Assignment required, proven: an unassigned user is blocked with AADSTS50105.
Sign-in log showing a successful SAML sign-in with Conditional Access applied
Sign-in log: the assigned user's SAML sign-in succeeds, with Conditional Access applied.

PIM. The user requested the eligible User Administrator role with a justification. The lab admin approved it from a separate session, and the role went live for four hours, the cap set in Phase 5. She used it to edit another user, then deactivated it early. The PIM audit log records the approval and the activation.

PIM active assignment of User Administrator ending four hours after activation
Activated after approval, ending four hours later.
PIM audit history showing request approved and activation completed
PIM audit: request approved by the lab admin, then activation completed.

Access package. A user requested Project IAM Access from the My Access portal. The request waited for the lab admin, who had to give a reason to approve it. The user was then added to the project group, with the assignment set to expire after 90 days.

Approver view of a pending access package request with a due date
The approver's view: who asked, for what, and a 14-day deadline to decide.
Project group showing the requester added after approval
After approval the requester is in the group. It was empty before the request.

Access review. I planted a finding by adding an HR user to the break-glass exclusion group, so she bypassed MFA. Before running the review, I checked the existing quarterly review and found it set to auto-apply and remove access when reviewers do not respond. On this group, one missed review would have removed the break-glass account's exclusion, the exact failure that account exists to survive. I changed it to "No change". A one-off review then recommended Approve for both members, because both had signed in recently. I kept the break-glass account, denied the HR user, and the review removed her from the group.

Access review settings: auto apply on, remove access if reviewers don't respond
Finding: auto-apply plus "Remove access" on the break-glass group.
Access review settings changed to No change if reviewers don't respond
Fixed: an unanswered review now leaves membership unchanged.
Access review recommending Approve for both members of the exclusion group
The helper recommends Approve for both. Accepting it would have kept the planted member.
Completed access review with one approved and one denied
Review complete: one approved, one denied, and the denied member removed.

Operational Testing • SSO • PIM • Entitlement Management • Access Reviews • Evidence

Lab vs Production

A few things were simplified because this is a lab in a trial tenant, and it is worth being clear about them:

Licensing: I assigned licences directly to users because the portal routed group-based licensing elsewhere. In production, group-based licensing is the correct choice because it makes offboarding atomic, reclaiming the licence the moment the group membership drops.

Hybrid identity: this lab was built cloud-only. I later synced the same tenant with a hardened Windows Server 2025 domain controller through Entra Connect in the hybrid hardening lab, and tested the hybrid joiner, mover and leaver scripts there.

Break-glass fail-closed: I first set the access review on the emergency-access group to fail closed. Testing in Phase 7 confirmed that an unanswered review would have removed the break-glass account's own exclusion, so the review now leaves membership unchanged when reviewers do not respond.

What I Tested

Tested end to end: dynamic groups populating from the department attribute, the mover re-scoped in both directions, a full leaver deprovision, both Conditional Access policies enforced with the break-glass exclusion proven in the sign-in logs, and the PIM remediation confirmed by the before-and-after role assignments. In Phase 7: an SSO sign-in and an unassigned-user block, a PIM activation with approval, an access package request with approval, and an access review that removed a member.

Not covered here: hybrid identity, which is in the hybrid hardening lab on the same tenant, and long-term log export to a SIEM.

The result is a working identity environment covering the SC-300 skill set (design, lifecycle, access control, governance, applications and workload identity), with the security reasoning behind each control.

SC-300 • Microsoft Entra ID • Identity & Access Management • Zero Trust • Identity Governance

The Scripts Behind It

The lifecycle and reporting work in this lab is scripted in entra-iam-automation: PowerShell with the Microsoft Graph SDK for joiners, movers and leavers (cloud-only and hybrid through Entra Connect), read-only reports for standing admins, stale accounts, MFA registration and risky app permissions, and access review campaigns that record their evidence. Every push is linted and unit-tested (Pester) in CI. The hybrid scripts were tested against a real AD and Entra Connect in the hybrid hardening lab.

View on GitHub Back to Projects