Account Termination Workflow¶
A step-by-step guide to building an HR/security-triggered workflow that revokes a departing employee's access role and disables their Active Directory account after manager approval. Approval denials end the run silently (no notification to the employee). Provisioning failures notify the approving manager instead of failing silently.
This matches the Account Termination starter in the New Workflow gallery. You can instantiate that starter and skip to Step 6 — Publish, or rebuild it by hand below.
Prerequisites¶
- A configured Active Directory connector (or the built-in
test-activedirectorymock connector for a dry run without a real directory). - A role the departing employee currently holds (the role this workflow will revoke), created under People → Roles.
- The
workflow:create,workflow:update,workflow:publish, andworkflow:readpermissions on your admin account (the Workflows tab andGET /api/workflowsare gated onworkflow:read), andtemplate:readif you instantiate the starter from the gallery. Starting a verification run (Step 6) also requiresworkflow:start.
Security model — read this before publishing¶
- Denials are silent on purpose. The only contact parameter is the
manager who just denied the request. Notifying them of their own denial
is circular; notifying the employee that a termination was
considered-but-denied would leak an internal HR/security deliberation.
The approval step's
errortransition goes straight to adeniedend node with no notification step. - Look the directory account up by email, not by username. The
test-activedirectorydisableAccountcommand keys users onsAMAccountName. Passing{{targetUser.email}}asusernamelooks up the email string as a map key and fails withUser not foundfor every real directory account (for examplejdoe/jdoe@corp.example.com). PassuserEmail: "{{targetUser.email}}"so the connector'sensureUsernameFromEmailhook can resolve the canonical username. - Do not claim an archive ran. This starter has no storage connector.
archiveBucketIdis instantiate-time metadata for the operator (where they expect archived data to live). Interpolating it into the success email either asserts an archive that never happened or, if the optional parameter is left blank, leaves a literal{{ARCHIVE_BUCKET_ID}}in the manager's inbox.
Overview¶
flowchart TD
Start[Start]
Approve["Manager approval"]
Revoke["Revoke access role"]
Disable["Disable AD account"]
NotifyOk[Notify manager — complete]
NotifyFail[Notify manager — failed]
Success[End: Success]
Failure[End: Failure]
Denied[End: Denied]
Start --> Approve
Approve -->|success| Revoke
Approve -->|error| Denied
Revoke -->|success| Disable
Revoke -->|error| NotifyFail
Disable -->|success| NotifyOk
Disable -->|error| NotifyFail
NotifyOk --> Success
NotifyFail --> Failure
Step 1 — Create the workflow¶
Navigate to Design in the sidebar (opens /workflows), open the
Workflows tab, and click New Workflow:
| Field | Value |
|---|---|
| Name | Account Termination |
| Description | Revoke access and disable the AD account after manager approval |
| Category | user |
| Subject Variable | targetUser |
| Error Strategy | stop |
| Trigger | manual |
Category is user (not user_self_service): this is an admin-initiated
offboarding flow, so targetUser is declared explicitly rather than
bound to the person who starts the run.
Step 2 — Variables¶
| Name | Type | Required | Description |
|---|---|---|---|
targetUser |
user | yes | Employee being offboarded (the subject). |
Step 3 — Build the graph¶
- Manager approval (
approval) —approversis the manager who must sign off.success→ revoke;error→ thedeniedend node (no notification). - Revoke access role (
role_revoke) —roleDefinitionIdis the role to take away;userIdis{{targetUser.id}}.error→ shared failure notification. - Disable Active Directory account (
connector) —
| Config key | Value |
|---|---|
connector |
test-activedirectory |
command |
disableAccount |
userEmail |
{{targetUser.email}} |
Do not set username to the email. error → shared failure
notification.
- Notify manager of successful termination (
notification) — internal recipient, the same manager. The body should report that the role was revoked and the directory account disabled. Do not mention an archive location unless a real archive step exists. - Notify manager of termination failure (
notification) — same recipient; include{{lastStepError.stepId}}and{{lastStepError.message}}. - Three end nodes:
success,failure, anddenied.
Step 4 — Parameters (if you save this as a template)¶
| Parameter | Required | Purpose |
|---|---|---|
managerUserId |
yes | Approver, and the recipient of success/failure notices. |
accessRoleId |
yes | Role definition revoked from the departing employee. |
archiveBucketId |
no | Operator metadata only. Not interpolated into any step. |
Step 5 — Connectors¶
Point the disable step at a real Active Directory connector before
production use. The starter uses test-activedirectory so the graph
runs in a dry environment.
Step 6 — Publish¶
Save, then Publish. Start a run with a test user whose directory
mail attribute matches targetUser.email and confirm the AD account
is disabled after the role revoke succeeds.