Skip to main content

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 classMGCWardenAuditRoleCapture
Menu itemMGCWardenAuditRoleCaptureMenuItem, label Role event capture
Menu pathSystem administration → Setup → Role event capture
Who may run itMGCWardenAuditAdministrationPriv (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 toggleWarden Evidence & Compliance (MGCWardenAuditReportingFeature). When it is off the run captures nothing, leaves the snapshot untouched and writes a ReportingFeatureOff self-audit row
Company scopePer 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 defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou 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 itRoleCaptureNotScheduled (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 recordNone. The batch log carries one summary line; the feature-off path also writes a self-audit row
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 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().

SettingWhereWhat it does here
Sensitive rolesSensitive roles (MGCWardenAuditSensitiveRole): role name, effective from and to, optional recipients overrideA grant of a role whose name matches an effective row raises the alert and the business event
Sensitive-role alert recipientsWarden audit compliance parameters, SensitiveAlertRecipientsSemicolon-separated user IDs. Used when the sensitive-role row has no RecipientsOverride
Publish compliance business eventsWarden audit compliance parameters, BusinessEventsEnabledGates 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​

  1. Feature gate. If MGCWardenAuditReportingFeature::isOn() is false, recordFeatureOff writes a ReportingFeatureOff self-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.
  2. Overlap guard, scoped to this company. A refused run leaves the snapshot alone.
  3. Grants (captureGrants). For every enabled assignment (SecurityUserRole.AssignmentStatus = Enabled, joined to SecurityRole) with no matching snapshot row, it records a granted event and then inserts the snapshot row in its own transaction.
  4. 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.
  5. Recording one event (recordEvent):
    • newRoleEvent builds the row before any transaction opens: TargetUser, ActionBy and RecordedBy through MGCWardenIdentityVault::refFor, Source = DiffDetected, EventDateTime = now, StoreForwarded = No. ActionBy is blank, because diff capture cannot see who made the change; RecordedBy is the account running the batch.
    • The role event is inserted in its own transaction.
    • forwardToStore appends a Write store row (RoleGrantChangeAttributed template, record key ROLE:...) and sets StoreForwarded = Yes, in one transaction. A failure here is swallowed: the role event stands with StoreForwarded = No.
    • For a grant, alertIfSensitive looks 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.
  6. 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​

DirectionTable or objectWhat
ReadsSecurityUserRole, SecurityRoleEnabled assignments, role name and AOT name
Reads, inserts, deletesMGCWardenAuditRoleSnapshotThe per-company snapshot
Inserts, updatesMGCWardenAuditRoleEventOne row per change; StoreForwarded set after forwarding
InsertsMGCWardenAuditEvent, MGCWardenAuditDetailParamOne Write store row per forwarded event; self-audit rows
ReadsMGCWardenAuditSensitiveRole, MGCWardenAuditComplianceParameters, UserInfoAlert matching and recipients
InsertsEventInboxSensitive-role alerts
SendsMGCWardenAuditSensitiveRoleGrantedBusiness event Warden sensitive role granted
Reads, insertsMGCWardenIdentityVaultThrough refFor
InsertsMGCWardenExecutionExceptionOne 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: RoleCaptureNotScheduled when 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-CAPTURE failures and overlap refusals.

Errors, recovery and troubleshooting​

SymptomCause and recovery
Error exception Role-assignment capture batch failedA 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 = NoThe 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 alertThe 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 historyExpected: 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.