Role event capture
Role event capture records every security-role grant and revocation as a durable role event, by comparing the current role assignments with a snapshot Warden keeps. It forwards each event to the audit store and alerts when a role on the sensitive-role list is granted.
At a glance
| Batch class | MGCWardenAuditRoleCapture |
| Menu item | MGCWardenAuditRoleCaptureMenuItem, label Role event capture |
| Menu path | System administration → Setup → Role event capture |
| Who may run it | MGCWardenAuditAdministrationPriv (granted at Update) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditRoleCapture is granted on the same privilege and re-checks the same menu item |
| Feature toggle | Warden Evidence & Compliance (MGCWardenAuditReportingFeature). When it is off the run captures nothing, leaves the snapshot untouched and writes a ReportingFeatureOff self-audit row |
| Company scope | Per legal entity. Role assignments (SecurityUserRole) belong to no company, but the snapshot (MGCWardenAuditRoleSnapshot), the role events (MGCWardenAuditRoleEvent), the sensitive-role list and the compliance parameters are per company. A run in each of two companies records the same change twice, once in each |
| Scheduled by default | No. Nothing in the product creates a batch job for it |
| Recurrence | You choose. A role event is stamped with the time the run noticed the change, not the time of the grant, so the recurrence is the resolution of the role history and the delay of the sensitive-role alert |
| Setup-gap rules watching it | RoleCaptureNotScheduled (code ROLECAPTURE): Warden Evidence & Compliance is on and no job of this class carries a recurrence in this company. Only a recurrence in this company clears it. RecipientsNoneResolve, RecipientsSomeResolve and SensitiveRecipientsNoRoles watch the alert configuration it uses |
| Run record | None. The batch log carries one summary line; the feature-off path also writes a self-audit row |
| Overlap guard | Yes. 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 role change is the most direct evidence of an access-control change, and SOX ITGC packs report it. Dynamics 365 keeps the current assignments but no history of them. This batch builds that history by snapshot diff and makes each change tamper-evident by forwarding it to the audit store.
The sensitive-role alert gives a short list of people immediate notice that someone was given, for example, a break-glass-bearing role.
How and when it is triggered
- Scheduled from the menu item, with a recurrence, in each company that should hold role history.
- Run now from the same menu item.
canRunInNewSession()returns true. - API:
MGCWardenBatchService.runAuditRoleCapture.
Nothing in the platform calls it when a role is granted.
Configuration and scheduling options
No dialog fields; pack() returns conNull().
| Setting | Where | What it does here |
|---|---|---|
| Sensitive roles | Sensitive roles (MGCWardenAuditSensitiveRole): role name, effective from and to, optional recipients override | A grant of a role whose name matches an effective row raises the alert and the business event |
| Sensitive-role alert recipients | Warden audit compliance parameters, SensitiveAlertRecipients | Semicolon-separated user IDs. Used when the sensitive-role row has no RecipientsOverride |
| Publish compliance business events | Warden audit compliance parameters, BusinessEventsEnabled | Gates the Warden sensitive role granted business event (MGCWardenGovernanceEventSender::canSendCompliance) |
See Configuration reference for defaults.
Choosing a recurrence. Because the event time is the capture time, a daily run says "granted some
time in the last day". A grant and revocation inside one interval is never seen. A shorter interval
costs a full read of SecurityUserRole and the snapshot per run.
What it does
- Feature gate. If
MGCWardenAuditReportingFeature::isOn()is false,recordFeatureOffwrites aReportingFeatureOffself-audit row (RoleCaptureSkipped) and an infolog line, and the run ends. The snapshot is deliberately not advanced, so the first run after the feature is switched back on reports the changes made meanwhile. - Overlap guard, scoped to this company. A refused run leaves the snapshot alone.
- Grants (
captureGrants). For every enabled assignment (SecurityUserRole.AssignmentStatus = Enabled, joined toSecurityRole) with no matching snapshot row, it records a granted event and then inserts the snapshot row in its own transaction. - Revocations (
captureRevocations). For every snapshot row with no enabled assignment behind it, it records a revoked event and then deletes the snapshot row in its own transaction. - Recording one event (
recordEvent):newRoleEventbuilds the row before any transaction opens:TargetUser,ActionByandRecordedBythroughMGCWardenIdentityVault::refFor,Source=DiffDetected,EventDateTime= now,StoreForwarded= No.ActionByis blank, because diff capture cannot see who made the change;RecordedByis the account running the batch.- The role event is inserted in its own transaction.
forwardToStoreappends aWritestore row (RoleGrantChangeAttributedtemplate, record keyROLE:...) and setsStoreForwarded= Yes, in one transaction. A failure here is swallowed: the role event stands withStoreForwarded= No.- For a grant,
alertIfSensitivelooks for an effective sensitive-role row. If one matches, it publishes the Warden sensitive role granted business event (when compliance business events are on), then inserts an in-client alert (EventInbox, pop-up, no email) for each recipient token that resolves to a user. The alert names the people in clear; the role event and the business event carry references.
- Writes the summary: grants and revocations recorded.
Transaction boundaries. The event insert, the store forward and the snapshot change are three separate transactions. The snapshot changes only after the event is recorded, so a failure before that leaves the change to be captured again by the next run.
Error scope. run() has one catch around the whole capture. The first error that escapes a step
ends the run there, files one Error execution exception (ROLE-CAPTURE), and leaves the remaining
changes for the next run. A failing identity vault stops the capture this way rather than recording a
clear user ID.
Concurrency. The snapshot has no unique key on user and role, so two captures in one company would record every change twice. The overlap guard prevents that for batch tasks in the same company; it cannot see an interactive Run now or an API call.
Dependencies and prerequisites
- The Warden Evidence & Compliance feature switched on.
- The identity vault able to issue references.
- Sensitive roles and recipients configured if alerts are wanted. Recipients are user IDs, not email addresses.
Inputs and outputs
| Direction | Table or object | What |
|---|---|---|
| Reads | SecurityUserRole, SecurityRole | Enabled assignments, role name and AOT name |
| Reads, inserts, deletes | MGCWardenAuditRoleSnapshot | The per-company snapshot |
| Inserts, updates | MGCWardenAuditRoleEvent | One row per change; StoreForwarded set after forwarding |
| Inserts | MGCWardenAuditEvent, MGCWardenAuditDetailParam | One Write store row per forwarded event; self-audit rows |
| Reads | MGCWardenAuditSensitiveRole, MGCWardenAuditComplianceParameters, UserInfo | Alert matching and recipients |
| Inserts | EventInbox | Sensitive-role alerts |
| Sends | MGCWardenAuditSensitiveRoleGranted | Business event Warden sensitive role granted |
| Reads, inserts | MGCWardenIdentityVault | Through refFor |
| Inserts | MGCWardenExecutionException | One Error per failed run |
Logging and monitoring
- Batch history: Warden role capture: N grant(s) and N revocation(s) recorded. or the feature-off message.
- Role event history (System administration → Setup → Role event history) is the auditor's view. The Role drift report is the administrator's live view.
- Setup gaps:
RoleCaptureNotScheduledwhen the feature is on and the batch has no recurrence in this company; recipient tokens that resolve to no user (RecipientsNoneResolve,RecipientsSomeResolve), and recipients configured with no effective sensitive role (SensitiveRecipientsNoRoles). - Execution exceptions:
ROLE-CAPTUREfailures and overlap refusals.
Errors, recovery and troubleshooting
| Symptom | Cause and recovery |
|---|---|
| Error exception Role-assignment capture batch failed | A step threw. The snapshot was not advanced for the change that failed, so the next run captures it. There is no Retry handler; fix the cause (often the identity vault) and run again |
Role events with StoreForwarded = No | The store forward failed. Not confirmed: no code path re-forwards such a row later; nothing in MGCWardenAuditRoleCapture or elsewhere selects StoreForwarded = No to try again. The row is kept for ever by role event retention, but it is not tamper-evident in the store |
| A grant did not alert | The role name does not match an effective sensitive-role row, or no recipient token is a user. Check the setup gaps page |
| The same change appears in two companies' role history | Expected: the capture runs per company. Evidence packs read role events across companies and label the section system-wide |
Impact on other functionality
- Evidence packs. The SOX ITGC AccessChanges section reads role events from every company and prints the company that recorded each row.
- Role event retention deletes role events older than seven years, and only those already forwarded; see Role event retention.
- Erasure. An erasure refuses while a disabled account still holds any role, because the next capture would record the role again and issue the account a new reference. The erasure deletes the person's snapshot rows.
- Audit store growth. Every recorded change appends one store row.