Hello All,
We have about 3K+ accounts on a source to be disabled. Is there a way to do it using the Workflow feature and if yes, can you please kick start me with some ideas. Thank you.
Best Regards,
Sowmithri V
Hello All,
We have about 3K+ accounts on a source to be disabled. Is there a way to do it using the Workflow feature and if yes, can you please kick start me with some ideas. Thank you.
Best Regards,
Sowmithri V
Workflows really shines when you want to perform a series of actions based on an event that happens in IdentityNow. If this is a one-off action that you need to perform irregularly, then you would probably be better off writing a script in a language like Python that utilizes the list accounts API to get all accounts for a given source, and then disable account API to do the disabling.
This script should work out of the box. The command that actually disables the accounts is commented out so you can do a test run first to make sure the accounts are correct. When you are ready to actually disable them, just uncomment the last line.
import requests
import json
# Populate these three variables with your details
tenant = "devrel"
accessToken = ""
sourceId = "2c9180877de347a1017e21d505831cd4"
headers = {
'Accept': 'application/json',
'Authorization': f'Bearer {accessToken}'
}
url = f'https://{tenant}.api.identitynow.com/v3/accounts?filters=sourceId eq "{sourceId}"&limit=250'
offset = 0
response = requests.request("GET", url + f'&offset={offset}', headers=headers).json()
accounts = response
while len(response) == 250:
offset += 250
response = requests.request("GET", url + f'&offset={offset}', headers=headers).json()
accounts = accounts + response
for account in accounts:
url = f'https://{tenant}.api.identitynow.com/v3/accounts/{account["id"]}/disable'
print(f'Disable account {account["id"]}: {account["name"]}')
#response = requests.request("POST", url, data=json.dumps({}), headers=headers).json()
You’ll need to install the requests
module first if you don’t have it. You can install it by running
pip install requests
Then, save this script to a file called disable-accounts.py
and run it.
python disable-accounts.py