Identity Bytes // IB-ENTRA-SEC Track
Advanced Lab 07 of 12 Est. 110 minutes

Just-in-Time Admin Access with Privileged Identity Management

Standing administrator rights are a permanent liability: every one is a credential worth stealing, around the clock. This lab converts Northgate's always-on admin assignments to eligible, time-bound, approval-gated activations with Privileged Identity Management, so privilege exists only when it is being used and every activation is justified and logged.

Section 1

Lab Metadata

Lab ID
IB-ENTRA-SEC-07
Difficulty
Advanced
Scenario Org
Northgate Financial
Estimated Time
110 minutes

Core technologies

Privileged Identity Management Eligible vs active roles JIT activation Role management policies Approval workflows Microsoft Graph PowerShell Entra ID P2
Section 2

Scenario and Description

IN PLAIN TERMS A bank does not let every teller carry the vault key in their pocket all day. They sign one out for the few minutes they need it, with a reason recorded, and hand it straight back. Standing admin rights are the vault key left in everyone's pocket around the clock. This lab moves administrators to signing the key out only when they need it, with a reason and, for the biggest vaults, an approval, while keeping one emergency master key permanently ready for a genuine crisis.

Your Lab 01 baseline listed Northgate's privileged role holders. Every one of them holds their admin role permanently, active every second of every day, whether they are performing an admin task or asleep. That is standing privilege, and it is the single largest movement in an attacker's favour: compromise any one of those accounts at any time and you inherit live admin rights immediately.

Privileged Identity Management (PIM) breaks this model. Instead of being permanently active in a role, an administrator is made eligible for it. When they need it, they activate the role for a bounded window, providing a justification, passing MFA, and, for the most sensitive roles, waiting for approval. When the window expires, the privilege evaporates. The account spends almost all of its life with no admin rights at all, so a stolen credential is worth far less.

This is the heart of the brief's requirement to "support the deployment and optimisation of Privileged Access Management" and to "implement least-privilege access principles". You will inventory standing privilege, tune the role activation policy, convert an administrator from permanently active to eligible, activate just-in-time as that user, and, crucially, keep your break-glass accounts as a deliberate exception so an emergency is never blocked by an activation workflow.

Section 3

Prerequisites

Prior labs

Labs 01 and 03 required. You use the jpatel administrator from Lab 01 and the break-glass accounts from Lab 03. PIM requires Entra ID P2, which your Lab 01 trial provides.

Graph scopes introduced

ScopeWhy it is needed
RoleManagement.ReadWrite.DirectoryRead assignments, create eligibility, activate and remove role assignments
RoleManagementPolicy.ReadWrite.DirectoryRead and adjust role activation policies
Directory.Read.AllResolve role definitions and principals
THE BREAK-GLASS EXCEPTION Do not place your emergency access accounts behind PIM. Break-glass accounts must hold permanent, active Global Administrator so they work instantly when everything else fails, including PIM itself. Putting them behind an activation workflow defeats their entire purpose. This lab makes admins eligible, but leaves break-glass permanently active by design.
Section 4

Real-World Problem Statement

Least privilege is not only about which roles someone has, it is about when they have them. A role held permanently is a role available to an attacker permanently. Reducing the time privilege is active is often a bigger risk reduction than reducing the number of people who hold it.

DimensionWhy this matters
RiskStanding admin rights are always-on attack value. JIT activation shrinks the window in which a compromised admin account is actually privileged to near zero.
ComplianceTime-bound, justified, approved privileged access with a full activation audit trail is a core control auditors look for.
ProductivityActivation takes seconds, and admins keep a clean record of exactly when and why they used privilege.
Security postureThis is the move that turns a list of permanent admins into a set of occasional, accountable elevations.

Concrete scenario: Northgate has 14 permanent administrators across sensitive roles. The CISO wants none of them permanently active by quarter end. Every elevation must require MFA and a justification, Global Administrator activations must require approval, and break-glass must remain instantly usable outside the whole workflow.

Section 5

Skills Mapped to Production Solutions

Skill learned in this labReal-world enterprise application
Inventorying standing versus eligible privilegeMeasuring and reducing the permanent-admin attack surface
Tuning role activation policiesEnforcing MFA, justification, duration and approval on elevation
Converting active assignments to eligibleRolling out just-in-time access across an admin population
Self-activating a role via Graph and portalDay-to-day privileged operations under least privilege
Designing the break-glass exceptionGuaranteeing emergency access survives the privileged-access model
Section 6

Architecture Overview

PIM introduces two states for a role: eligible (you may activate it) and active (you currently hold it). Administrators live in the eligible state and activate briefly on demand. Break-glass accounts stay permanently active, outside the workflow.

jpatel: ELIGIBLE User Administrator no rights right now Activation gate justification required MFA required approval (high roles) max 8 hours every activation logged jpatel: ACTIVE rights for 8h, then gone break-glass permanent, outside PIM activate bypasses gate
PRODUCTION CONSIDERATION Roll out PIM by making people eligible before you remove their permanent assignment, and confirm they can activate successfully. Removing standing access from an admin who cannot yet activate leaves them unable to work. Eligibility first, removal second, exactly the availability-before-removal discipline from Lab 02.
Section 7

Step-by-Step Implementation

Phase A - Inventory standing privilege

1List permanent active role assignments

Purpose: identify who holds admin rights permanently, the population to convert.

Enumerate active assignments and resolve names
Connect-MgGraph -Scopes 'RoleManagement.ReadWrite.Directory',
  'RoleManagementPolicy.ReadWrite.Directory','Directory.Read.All' -NoWelcome

# Active (currently effective) directory role assignments.
$assignments = Get-MgRoleManagementDirectoryRoleAssignment -All -ExpandProperty Principal

$assignments | ForEach-Object {
  $roleDef = Get-MgRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId $_.RoleDefinitionId
  [pscustomobject]@{
    Role      = $roleDef.DisplayName
    Principal = $_.Principal.AdditionalProperties['userPrincipalName']
    Type      = ($_.Principal.AdditionalProperties['@odata.type'] -replace '#microsoft.graph.','')
    AssignmentId = $_.Id
  }
} | Sort-Object Role | Format-Table -AutoSize
VERIFICATION You see jpatel as a permanent User Administrator and your own account as Global Administrator, plus the two break-glass accounts. These permanent assignments are what PIM replaces with eligibility, except break-glass.

Phase B - Tune the activation policy

REAL WORLD ANALOGYThe activation policy is the rules written on the key sign-out sheet: how long the key may be out (8 hours, never overnight), what you must show to take it (MFA), what you must write down (a reason), and which keys need the duty manager's countersignature (approval, reserved for the biggest vault). Enterprises tune these rules per role, friction proportional to the damage the key could do.

2Set the role activation rules

Purpose: require MFA, justification, a bounded duration, and approval for the most sensitive roles.

Context: each role has a role management policy governing activation. The rule set is fiddly to edit purely in Graph, so tune it in the portal with the precise settings below, and read it back via Graph to confirm.

Portal settings, then read the policy via Graph
# PORTAL: entra.microsoft.com > ID Governance > Privileged Identity Management >
#   Microsoft Entra roles > Settings > select 'User Administrator' > Edit.
#
# Activation:
#   Maximum activation duration = 8 hours
#   Require multi-factor authentication on activation = Yes
#   Require justification on activation = Yes
#   Require approval to activate = No (for User Administrator)
#
# For 'Global Administrator', repeat with:
#   Require approval to activate = Yes, and name specific approvers.
#   Require phishing-resistant MFA (ties to Lab 04) if configured.
#
# READ BACK via Graph to confirm the policy exists for the role scope:
$polAssign = Get-MgPolicyRoleManagementPolicyAssignment `
  -Filter "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq 'fe930be7-5e62-47db-91af-98c3a49a38b1'"
Get-MgPolicyRoleManagementPolicyRule -UnifiedRoleManagementPolicyId $polAssign.PolicyId |
  Select-Object Id, AdditionalProperties
INFO: why 8 hours and why approval only for Global Admin A maximum of 8 hours covers a working day without leaving privilege active overnight. Approval adds friction, so reserve it for the highest-impact roles such as Global Administrator, where a second human in the loop is worth the delay. Lower-impact roles use MFA and justification without approval to keep operations fluid.

Phase C - Make jpatel eligible, then remove standing access

REAL WORLD ANALOGYOrder matters: you add someone's name to the sign-out register before you take their permanent key away. Do it the other way round and they stand keyless at the vault with a queue of work behind them. Availability before removal is the same discipline as the SMS migration: the new path must demonstrably work before the old one is withdrawn.

3Create an eligible assignment for User Administrator

Purpose: give jpatel the ability to activate the role on demand, before removing the permanent one.

Create the eligibility via a schedule request
$domain  = (Get-MgOrganization).VerifiedDomains | Where-Object IsDefault | Select-Object -ExpandProperty Name
$jpatel  = Get-MgUser -Filter "userPrincipalName eq 'jpatel@$domain'"
$roleDefId = 'fe930be7-5e62-47db-91af-98c3a49a38b1'   # User Administrator

New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter @{
  action           = 'adminAssign'
  principalId      = $jpatel.Id
  roleDefinitionId = $roleDefId
  directoryScopeId = '/'
  justification    = 'Move jpatel to eligible JIT for User Administrator'
  scheduleInfo = @{
    startDateTime = (Get-Date).ToString('o')
    expiration    = @{ type = 'noExpiration' }   # eligibility persists; recertified via access reviews (Lab 08)
  }
}
VERIFICATION
Get-MgRoleManagementDirectoryRoleEligibilitySchedule `
  -Filter "principalId eq '$($jpatel.Id)'" |
  Select-Object RoleDefinitionId, Status, MemberType
# Expected: an eligibility schedule for the User Administrator role.

4Remove the permanent active assignment

Purpose: take away the always-on rights now that jpatel can activate on demand.

Delete the standing assignment (only after eligibility is confirmed)
# Find jpatel's permanent active User Administrator assignment.
$perm = Get-MgRoleManagementDirectoryRoleAssignment -All `
  -Filter "principalId eq '$($jpatel.Id)' and roleDefinitionId eq '$roleDefId'"

# Remove it. jpatel now holds the role only when activated.
if ($perm) {
  Remove-MgRoleManagementDirectoryRoleAssignment -UnifiedRoleAssignmentId $perm.Id
  Write-Host 'Permanent User Administrator assignment removed for jpatel.' -ForegroundColor Green
}
SECURITY WARNING Confirm the eligibility from Step 3 exists before running this. Removing the permanent assignment without a working eligibility would leave jpatel unable to perform admin tasks at all. Never remove your own last standing path to Global Administrator, that is what break-glass and eligibility are for.

What just happened? jpatel has gone from permanently privileged to occasionally privileged. Their account now spends most of its life with no admin rights, so a credential theft yields far less, and any use of privilege is a deliberate, logged act.

Phase D - Activate just-in-time

5Self-activate the role for a bounded window

Purpose: experience the day-to-day flow, elevate briefly with a justification, then let it expire.

Context: activation is performed by the user themselves. jpatel does this from the portal or via Graph while signed in as jpatel.

Activate via the portal, or via Graph as jpatel
# PORTAL (as jpatel): entra.microsoft.com > PIM > My roles >
#   Microsoft Entra roles > Eligible assignments > User Administrator > Activate.
#   Provide a justification, complete MFA, choose a duration up to 8 hours.
#
# GRAPH (signed in as jpatel):
$me = Get-MgUser -UserId (Get-MgContext).Account
New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter @{
  action           = 'selfActivate'
  principalId      = $me.Id
  roleDefinitionId = 'fe930be7-5e62-47db-91af-98c3a49a38b1'
  directoryScopeId = '/'
  justification    = 'Onboarding three new joiners this afternoon'
  scheduleInfo = @{
    startDateTime = (Get-Date).ToString('o')
    expiration    = @{ type = 'afterDuration'; duration = 'PT8H' }   # 8-hour window
  }
}
VERIFICATION
# As an admin, confirm the active (activated) instance and its expiry:
Get-MgRoleManagementDirectoryRoleAssignmentScheduleInstance `
  -Filter "principalId eq '$($jpatel.Id)'" |
  Select-Object RoleDefinitionId, StartDateTime, EndDateTime, AssignmentType
# AssignmentType 'Activated' with an EndDateTime ~8 hours out.

What just happened? jpatel elevated for a defined window with a recorded reason. When the window closes, the rights disappear automatically with no cleanup needed. The activation, the justification and the expiry are all in the audit log, ready for review.

Phase E - Protect the break-glass exception

REAL WORLD ANALOGYThe fire brigade's master key is never put behind the sign-out desk. If the desk is on fire, or the sign-out system itself has failed, that key must still turn instantly. This is why break-glass accounts keep permanent, always-active rights outside the whole activation workflow: an emergency path gated by the system it is meant to rescue is a contradiction.

6Confirm break-glass stays permanently active

Purpose: ensure your emergency path is not accidentally swept into PIM.

Verify break-glass holds permanent Global Administrator
foreach ($n in 1..2) {
  $bg = Get-MgUser -Filter "userPrincipalName eq 'breakglass$n@$domain'"
  $a = Get-MgRoleManagementDirectoryRoleAssignment -All -Filter "principalId eq '$($bg.Id)'"
  [pscustomobject]@{
    Account = $bg.UserPrincipalName
    HasPermanentRole = [bool]$a
  }
} | Format-Table -AutoSize
# Expected: HasPermanentRole = True for both break-glass accounts.
CRITICAL Break-glass accounts must never be made eligible-only. If an incident takes out MFA, an identity provider or PIM itself, a permanently active break-glass account is your guaranteed way back in. Verify their standing access remains, and keep the sign-in alerting on them from Lab 03 active so any real use is noticed immediately.
Section 8

Testing and Validation

  1. Eligibility: confirm jpatel appears under eligible assignments and holds no active User Administrator rights when not activated.
  2. Activation: as jpatel, activate the role with a justification and MFA, then confirm an active instance exists with an expiry.
  3. Expiry: after the window (or by ending the activation early), confirm the active instance is gone and rights are removed.
  4. Approval (Global Admin): configure approval on Global Administrator, request activation, and confirm it waits for approver action.
  5. Break-glass: confirm both emergency accounts still hold permanent Global Administrator outside PIM.
SymptomCauseResolution
jpatel cannot activateNo eligible assignment, or activation policy blocks themConfirm the eligibility schedule and that MFA and justification are satisfiable
Activation succeeds but no rightsDirectory replication delayAllow a short propagation window, then re-check
Cannot remove permanent assignmentIt is the last Global Administrator, or a protected assignmentNever remove the last standing GA, keep break-glass and at least one recoverable path
Policy read returns nothingWrong role definition id or scope in the filterUse the correct template id and scope /
Section 9

Security Analysis

What makes this sound

Intentionally simplified for the lab

Production hardening

Section 10

Cleanup Instructions

INFO: preserve for the track Keep jpatel eligible and break-glass permanent, Lab 08 recertifies this eligibility with access reviews. Only revert to reset the tenant.
Restore a permanent assignment and remove eligibility (reset only)
$domain = (Get-MgOrganization).VerifiedDomains | Where-Object IsDefault | Select-Object -ExpandProperty Name
$jpatel = Get-MgUser -Filter "userPrincipalName eq 'jpatel@$domain'"
$roleDefId = 'fe930be7-5e62-47db-91af-98c3a49a38b1'

# Recreate a permanent active assignment if you want jpatel back to standing admin.
New-MgRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter @{
  action='adminAssign'; principalId=$jpatel.Id; roleDefinitionId=$roleDefId; directoryScopeId='/'
  justification='reset'; scheduleInfo=@{ startDateTime=(Get-Date).ToString('o'); expiration=@{ type='noExpiration' } } }

# Remove the eligibility.
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter @{
  action='adminRemove'; principalId=$jpatel.Id; roleDefinitionId=$roleDefId; directoryScopeId='/'
  justification='reset' }
Disconnect-MgGraph
Section 12

Key Takeaways and Next Lab

Identity Bytes // IB-ENTRA-SEC Track // Lab 07 of 12. British English. For lab and training use against a disposable tenant only.