Environment
Brief Overview
My script processes inactive accounts and, for each user that must be removed, it:
# Remove from non‑Enterprise groups
for grp in user_to_delete.groups:
if getattr(grp, "provider", None) != "enterprise":
grp.remove_users([user_to_delete])
# Re‑assign owned items
user_to_delete.reassign_to('admin_account')
# Attempt delete
not_deleted = gis.users.delete_users([user_to_delete]) # returns [] on success
if not_deleted:
print(f"Delete FAILED for: {', '.join(not_deleted)}")
else:
print(f"User '{username}' successfully deleted.")
Problem
When I then call the bulk‑delete method, it returns the username of the user I'm attempting to delete which, according to the docs, means that the delete failed.
The Portal logs do not provide any additional insight into why the delete fails. The documentation for the delete_users method states that "before the administrator can remove the user, all of the user’s content and groups must be reassigned or deleted". The only groups that this user is still a member of are groups where the membership is based on a SAML group which they cannot be removed from with the remove_users method.
Workarounds
I can manually delete the user with the 'Delete member' option in the Members page despite their membership in these AD-synced groups but the point of this Notebook is to automate that process.
The users.delete method works but seemingly requires setting the credentials explicitly (which I would rather avoid):
gis = GIS("https://myportal/portal", "admin_account", "password")
user = gis.users.get(username)
user.delete()
Questions