Select to view content in your preferred language

Delete a Portal user that owns a group

581
2
01-18-2024 01:39 PM
Dan_Brumm
Frequent Contributor

I have a script that iterates a list of Portal usernames, searches for them, and deletes the account.    I THOUGHT if a user owned a group it would cause the delete user method to fail. 

 What I think happened when I ran my script was if the user owned a group, it went and unshared all the items in the group, deleted the group and then the user.   

 

Am I crazy or is that how its supposed to work??

 

 

Daniel Brumm
GIS Nerd
2 Replies
jcarlson
MVP Esteemed Contributor

There are two ways to delete users. One is User.delete(), which lets you optionally supply a reassign_to parameter to move all their content to another user first.

The second is UserManager.delete_users(), but that method will only work if the user owns no content.

If you did not supply a "reassign_to" parameter, or were using the second method, the delete should have failed. Can you confirm if your script does this?

- Josh Carlson
Kendall County GIS
0 Kudos
Dan_Brumm
Frequent Contributor

My script used the first method user.delete and I didn't use the reassign parameter. I thought that would prevent it from deleting any users that owned a group.   I had to recover the groups that were deleted. I am going to run my script again and try the reassign parameter this time.  fingers crossed.

Daniel Brumm
GIS Nerd
0 Kudos