Skip to main content

HR deprovisioning scan and leaver intake

The HR deprovisioning scan puts every leaver who still has an enabled account on the deprovisioning queue. It reads leavers from Dynamics 365 HR and, in a second pass, from leaver records imported from an external HR system. It proposes only: Warden revokes nothing, and a person removes the access outside Warden and attests it, or excepts the entry with a reason.

At a glance​

Batch classMGCWardenAuditDeprovisioning, which calls MGCWardenAuditLeaverIntakeProcessor::processCompany for the external-HRIS pass
Menu itemMGCWardenAuditDeprovisioningMenuItem, label HR deprovisioning scan
Menu pathSystem administration → Setup → HR deprovisioning scan
Who may run itMGCWardenAuditAdministrationPriv (granted at Update) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditDeprovisioning is granted on the same privilege and re-checks the same menu item
Feature toggleWarden Evidence & Compliance (MGCWardenAuditReportingFeature). When it is off no worker or intake record is read and a ReportingFeatureOff self-audit row is written. Attesting and excepting entries are not gated
Company scopePer legal entity. HR is shared, but each leaver is proposed only by the scan of the company whose legal entity employed them last. Entries, intake records and compliance parameters are per company. Schedule the scan in every legal entity that employs people
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose. The SLA clock starts when the entry is proposed, so the recurrence adds directly to how long a leaver keeps access before anyone is asked to act
Setup-gap rules watching itDeprovisioningScanNotScheduled (a legal entity that employs people and has no recurring scan, shown on every company's page, only while Warden Evidence & Compliance is on); DeprovisioningPastSla (proposed entries past their SLA date)
Run recordNone. The batch log carries summary lines; entries and intake record statuses are the output
Overlap guardYes. MGCWardenBatchOverlapGuard::refuses runs after the feature gate and refuses while another task of this class is executing in the same company

Purpose and business justification​

A leaver who keeps an enabled account is a standing access-control failure, and SOX ITGC asks for evidence that access is removed on termination. Dynamics 365 does not link a termination in HR to the user account. The scan does that, and the queue gives each leaving one owner, one SLA date and one recorded decision.

The scan never disables an account or removes a role. Automatic deprovisioning would make a data error in HR lock people out; Warden keeps the removal a deliberate human act and records the decision.

Many customers keep HR outside Dynamics 365. The leaver intake lets their HR system send leavers in, sealed into a per-company hash chain on arrival, and the same scan puts them on the same queue under the same SLA.

How and when it is triggered​

  • Scheduled from the menu item, with a recurrence, in each legal entity.
  • Run now from the same menu item. canRunInNewSession() returns true.
  • API: MGCWardenBatchService.runAuditDeprovisioning.

Leaver intake records arrive through the data entity Warden leaver intake records (WardenAuditLeaverIntake, data management and OData) into the company they are imported into. Nothing processes a record at import; the next scan in that company does.

Configuration and scheduling options​

No dialog fields; pack() returns conNull().

SettingWhereDefaultEffect
Deprovisioning SLA (days)Warden audit compliance parameters, DeprovisioningSlaDays7SLA date of a new entry = today + this. 0 or less is treated as 7

The overdue alert recipients and re-alert interval on the same page are used by Deprovisioning overdue monitor.

Choosing a recurrence. Daily is the natural choice: HR terminations are dated by day and the SLA is in days. Each run reads every worker once, plus one employment read per worker, so cost grows with the number of workers, not leavers.

What it does​

feature on? --no--> ReportingFeatureOff row, stop
overlap guard (this company)
D365 HR pass: for each worker
last employment (any legal entity) ended? enabled accounts? last employed HERE?
per account: answered already? --no--> Proposed entry (roles snapshot, SLA date)
external-HRIS pass (this company's intake records)
verify intake chain --> for each open record: match --> link or raise
  1. Feature gate. If Warden Evidence & Compliance is off, writes a DeprovisioningScanSkipped self-audit row and ... An empty queue is NOT a statement that every leaver's account is disabled., and stops.
  2. Overlap guard, in this company.
  3. D365 HR pass, for every worker (HcmWorker):
    • finds the employment that ends last in any legal entity (lastEmployment, reading full HcmEmployment history). A worker is a leaver only when that employment has ended; a transfer to another legal entity proposes nothing;
    • reads every account linked to the person now and enabled (enabledAccountsOf, through DirPersonUser and UserInfo). None, nothing to do;
    • only if this company's legal entity is that last employment's (lastEmployedHere), proposes each account through proposeLeaver: if no entry answers for that account and that leaving (answeringEntry: an open entry, or one attested or excepted since the employment ended, an attested one only while the access it saw removed has not come back), it inserts a Proposed MGCWardenAuditDeprovisioningEntry with the worker, the account, a snapshot of the account's roles and the SLA date;
    • counts leavers with an enabled account that another legal entity's scan owns.
  4. External-HRIS pass (MGCWardenAuditLeaverIntakeProcessor::processCompany):
    • walks this company's leaver intake chain first (MGCWardenAuditLeaverIntakeChain::verifyAndRecord). A broken chain files a Critical execution exception and records the verdict, but does not stop the pass;
    • for each open record (Received, Matched, waiting for the scan, Matched, no enabled account, Matched, hired again in D365 since), in its own transaction under pessimisticlock, asks MGCWardenAuditLeaverIntakeMatcher to decide. A record that is ready is linked to an entry that already answers for that account and leaving, or raises a new entry with Source = external HR system. An unmatched record is quarantined. A record whose person was rehired in D365 after the leaving raises nothing;
    • a record raises or links at most one entry, for one account. If the person holds other enabled accounts, the record's reason says so and asks for one record per account;
    • a record that throws stays open; the pass files one deduplicated Error exception (LEAVER-INTAKE) for all such records in the run.
  5. Writes Warden deprovisioning: N proposal(s) created., the intake pass's counts, and, when relevant, the count of leavers left to another legal entity's scan.

A failure outside the per-record catch ends the run and files one Error exception, Deprovisioning proposal batch failed. (document key DEPROVISIONING).

Idempotency. The scan re-derives everything from HR each run and asks answeringEntry before each insert, so a second run proposes nothing new. The overlap guard keeps two batch tasks apart; it cannot see an interactive Run now or an API call, so two of those at once can propose a leaver twice.

Dependencies and prerequisites​

  • Warden Evidence & Compliance switched on.
  • Workers, employments and person-to-user links maintained in Dynamics 365 HR, for the HR pass.
  • For the external pass: the HR system importing records into the right company through the entity.
  • The scan scheduled in each legal entity that employs people.
  • Deprovisioning overdue monitor scheduled, so overdue entries alert someone.

Inputs and outputs​

DirectionTableWhat
ReadsHcmWorker, HcmEmployment (all history), DirPersonUser, UserInfo, SecurityUserRole, SecurityRoleLeavers, accounts and roles
Reads, insertsMGCWardenAuditDeprovisioningEntryNew Proposed entries
Reads, locks, updatesMGCWardenAuditLeaverIntakeStatus, reason, matched account, linked entry
Reads, updatesMGCWardenAuditLeaverIntakeChainHeadChain verdict
ReadsMGCWardenAuditComplianceParametersSLA days
InsertsMGCWardenAuditEventReportingFeatureOff self-audit row when the feature is off
InsertsMGCWardenExecutionExceptionRun failure, intake evaluation failures, broken chain

Logging and monitoring​

  • Deprovisioning queue (System administration → Setup → Deprovisioning queue): open and decided entries, with Take, Assign, Attest access already removed and Except from deprovisioning.
  • Leaver intake records (System administration → Setup → Leaver intake records): each record's status and reason, the chain verdict, and Withdraw record.
  • Setup gaps: DeprovisioningScanNotScheduled per legal entity, DeprovisioningPastSla.
  • Evidence packs: the SOX ITGC DeprovisioningQueue section reports the queue and the intake as at build time.
  • Batch history: the summary lines above.

Screenshot to add: the Deprovisioning queue with one Proposed entry, its roles snapshot and SLA date.

Errors, recovery and troubleshooting​

SymptomCause and recovery
Error Deprovisioning proposal batch failed.The run failed part-way. Entries already inserted stand. Run again; the scan is stateless
A leaver is not proposedThey still have an employment open in some legal entity; their accounts are all disabled; an entry already answers for that account and leaving; or their last employment was in a legal entity that does not run the scan (see the message bar and DeprovisioningScanNotScheduled)
A leaver was proposed againAn earlier attestation saw access removed and the account has access again, or the person left again after a rehire. The entry's Proposed again because says which
Intake record Quarantined, not matchedThe record matched no one here. Quarantined is final and cannot be withdrawn; correct the data and send a new record
Intake record stays Matched, no enabled accountThe account is disabled. It is re-evaluated on every scan and raises an entry if the account is enabled again
Critical exception about the leaver intake chainA sealed intake record no longer matches its digest. Treat it as a tamper finding
Error LEAVER-INTAKESome records could not be evaluated. They stay open; fix the cause and run again

The class does not implement BatchRetryable. run() catches every failure, so the task ends normally.

Impact on other functionality​

  • Overdue monitor alerts on Proposed entries past their SLA date.
  • Attest and Except (on the queue) are not batch steps. Each writes a decision event, converts the entry's account and worker to subject references, and takes the entry off the open list.
  • Integrity batch publishes each company's leaver intake chain head on every run; see Audit chain integrity: anchoring, publication and verification.
  • Retention cleanup removes final intake records past the evidence window; see Warden retention cleanup.
  • Erasure of a person is refused while one of their deprovisioning entries is still Proposed; see Erasure execution.