EnumerateRoles
The script will enumerate any provided role names and output the list of users for each role.
python · Team Management
Source
import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 # Get arguments and obtain the roles args = demisto.args() roles = args.get("roles", "").split(",") parsed_data = [] # Get a list of all users in XSOAR all_users = demisto.executeCommand("getUsers", {})[0]["Contents"] # For each provided role, check the user to see if they are a member and if so # add them to the parsed_data list for role in roles: parsed_data.append({"role": role, "users": [x.get("username") for x in all_users if role in x.get("allRoles", [])]}) # Build the command results data command_results = CommandResults( outputs_prefix="Roles", outputs_key_field="role", outputs=parsed_data, readable_output=tableToMarkdown(f"Role enumeration for {roles}:", parsed_data), ) # Output the command results data return_results(command_results)
README
The script will enumerate any provided role names and output the list of users for each role.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Tags |
Inputs
| Argument Name | Description |
|---|---|
| roles | CSV of role names to enumerate |
Outputs
| Path | Description | Type |
|---|---|---|
| Roles.role | Role name | string |
| Roles.users | List of users in the role | string |