How to Remove Deactivated Users from All Groups Using Okta Workflows

In this guide:

Okta Workflows guides

Okta Workflows guides offer questions and answers from the Okta Workflows community office hours. They also come from the #okta-workflows channel on the Mac Admins Slack and other places. Read all the other guides.

How do you remove deactivated users from all groups using Okta Workflows?

This guide will teach you how to remove deactivated users from all groups using Okta Workflows.

Remove deactivated users from groups

The automation has three flows:

  • List users: flow lists all deactivated users and passes them to a helper flow.
  • Remove user: flow removes the user from each group.
  • List user groups: flow lists all groups for each deactivated user and passes them to a helper flow.

List users flow

The List users flow lists all deactivated users and passes them to a helper flow.

List deactivated users.
List deactivated users.

How the flow works

  1. The flow runs on a schedule.
  2. The Okta-List Users with Search card lists all users with a status of DEPROVISIONED. It uses the streaming option, passing each user to the List user groups helper flow.

List user groups flow

The List user groups flow lists all groups for each deactivated user and passes them to a helper flow.

List user groups.
List user groups.

How the flow works

  1. Since the main flow uses streaming, the Helper Flow card sets up the Record and State fields. Learn how to stream records to a helper flow.
    • The Record object holds each user object passed from the main flow. The Record extracts the ID property from the user JSON object.
  2. The Okta-Get Users Groups card lists all the users’ groups. It uses the streaming option, passing each group to the Remove user helper flow. The card also passes the User ID to the helper flow using the State field.

Remove user flow

The Remove user flow removes the user from each group.

Remove a user from group.
Remove a user from group.

How the flow works

  1. Since the List user groups flow uses streaming, the Helper Flow card sets up the Record and State fields.
    • The Record object holds each group object passed from the helper flow. The Record extracts two properties from the group JSON object: ID and Profile.Name.
    • The State object holds the User ID passed from the List user groups flow.
  2. The Branching-Continue If card checks that the group name is not equal to Everyone. The Everyone group is managed by Okta and cannot be modified. If the group is Everyone, the flow stops with the message: “Can’t remove from the Everyone group.”
  3. The Okta-Remove User from Group card removes the user from the group using the Group ID and User ID.

Okta Workflows resources

2 responses to “How to Remove Deactivated Users from All Groups Using Okta Workflows”

  1. I think this workflow could be enhanced by adding a filter by deactivation date, for example, for those who were deactivated more than 90 days ago, so that it would be easy to restore access to users who were deactivated by mistake or to returning contractors.

    1. Yes, a filter would make the automation more flexible. Right now, the flow returns all the deactivated users.

Leave a Reply

Discover more from Max Katz

Subscribe now to keep reading and get access to the full archive.

Continue reading