My goal is to delete 90 day inactive users programmatically. While I am somewhat successful in doing that, I came across a situation where the user owns items that are shared to a special group. This is raising an exception (Error Code: 400) Unable to reassign user. User must not own items shared to a special group.
How could I handle this programmatically? Am I missing anything here.
Thanks.
-Naari
Solved! Go to Solution.
Man, I really hate the "special groups" thing. It makes dealing with user content so much harder in situations like this. At my prior org, we actually decided to eliminate those groups rather than deal with the hassle they created.
To identify "special" groups, you can iterate over the groups and look at the 'capabilities' property and see if 'updateitemcontrol' is in there. That's the key for it being one of these "special groups".
I haven't tested this again content in a Site or Hub group, but know that there are also items in 'capabilities' that indicate those groups as well, and they may confer "special" status.
If 'updateitemcontrol' is all we want, we can use this code to get a list of the groups which have this capability:
special_groups = [grp.title for grp in gis.groups.search('') if 'updateitemcontrol' in grp.capabilities]
special_groups
Which returns
['Kendall County IL GIS Open Data Core Team', 'Testing Core Team']
With that list, you can look at the items a given user owns, and if that item belongs to a special group, have the script manually reassign ownership or adjust the sharing settings on that specific Item.
Alternatively, if it's easier, iterate through the content in each group, and if it belongs to the user in question, make the adjustment there. That can be easier than iterating over a user's content folders.
Man, I really hate the "special groups" thing. It makes dealing with user content so much harder in situations like this. At my prior org, we actually decided to eliminate those groups rather than deal with the hassle they created.
To identify "special" groups, you can iterate over the groups and look at the 'capabilities' property and see if 'updateitemcontrol' is in there. That's the key for it being one of these "special groups".
I haven't tested this again content in a Site or Hub group, but know that there are also items in 'capabilities' that indicate those groups as well, and they may confer "special" status.
If 'updateitemcontrol' is all we want, we can use this code to get a list of the groups which have this capability:
special_groups = [grp.title for grp in gis.groups.search('') if 'updateitemcontrol' in grp.capabilities]
special_groups
Which returns
['Kendall County IL GIS Open Data Core Team', 'Testing Core Team']
With that list, you can look at the items a given user owns, and if that item belongs to a special group, have the script manually reassign ownership or adjust the sharing settings on that specific Item.
Alternatively, if it's easier, iterate through the content in each group, and if it belongs to the user in question, make the adjustment there. That can be easier than iterating over a user's content folders.
I really like your post.
This code is great, I got thrown into doing this so I am in murky water.
Would you be willing to share your code?
This worked. Thank you.
-Naari