Select to view content in your preferred language

Identify users outside partnered collaboration (groups)

266
2
07-11-2025 07:26 AM
Labels (2)
Nordpil
Emerging Contributor

Hi all!

My organization have multiple partnered collaborations and we have groups (that we own) but where there are admins from the partners.

Now I want to change a group from the "any organization" membership setting to the more restricted "Partnered collaboration and my organization's members only", but I can't due to there being a current member that outside partnered collaborations/organizations.

I have tried various methods, including python and rest api to get information on the group members, but I haven't found a way to identify users that could/should be removed...

How can I identify and remove those members?

Any method is fine, but preferably REST API or python arcgis!

Thanks!

0 Kudos
2 Replies
ChristopherCounsell
MVP Frequent Contributor

Get all users in the group then check their orgid against your or your partnered orgs. It should be available as a property.

Here's sample code from AI. I haven't tested it. Would definitely recommend reviewing it before removing users. Sometimes it can be tricky to get users or information when they are not in your org.

from arcgis.gis import GIS

gis = GIS("home")

GROUP_ID = "your_group_id_here"
PARTNER_ORG_IDS = ["abc1234567890", "def987654321"]

my_org_id = gis.users.me.orgId
allowed_org_ids = [my_org_id] + PARTNER_ORG_IDS

group = gis.groups.get(GROUP_ID)
group_members = group.get_members()
all_members = group_members['owner'] + group_members['admins'] + group_members['users']

external_users = []

for username in all_members:
user = gis.users.get(username)
if user:
if user.orgId not in allowed_org_ids:
external_users.append((username, user.orgId))

for username, org_id in external_users:
print(f"{username}, {org_id}")

https://developers.arcgis.com/rest/users-groups-and-items/user/

Tags (1)
0 Kudos
Nordpil
Emerging Contributor

@ChristopherCounsell I have tried that, but I am unable to get any information in the user object for users that are not in my organization. (I can't even get the full name)

0 Kudos