From anonymous, 1 Month ago, written in Python.
Embed
  1. try:
  2.     print('Retrieving users . . .')
  3.     inactive_users = retrieve_inactive_users_mock_ad() # Retrieve users from user directory
  4.     if not inactive_users:
  5.         print('No entries retrieved. Exiting script.')
  6.         exit()
  7.     print(f'Retrieved {len(inactive_users)} entries. ')
  8.     for user in progressbar.progressbar(inactive_users, redirect_stdout=True):
  9.         api_user = retrieve_api_user() # GET request to an API for the user
  10.         if not api_user:
  11.             create_api_user(str(), str(user.displayName), str(user.userPrincipalName)) # POST request to API for creating user
  12.             continue
  13.         if api_user_disabled(api_user): # Check if user is already disabled
  14.             continue
  15.         disable_api_user(api_user.username, api_user.displayName) # PUT request to API to disable user