Hello,
I want to list all users and their groups. Actually, the script looks like this:
user_accounts = gis.users.search()
for user in user_accounts:
print(user.firstName, ";", user.email, ";", user.groups)
The output should look like this:
user1 ; user1@email.com ; group1, group2, group3
Without "user.groups" the skript is working. When querying "user.groups", a error appers.
How do I query the groups for each user?
Thank you in advance!
Solved! Go to Solution.
The issue was, that this approach needs a Level 2 Named User.
Even if a level 1 named user has the rights to see all groups and members, it is not the same with the python api.
I tested the lines with a level 2 named user and it worked. The groups are returned as array.
Hi Michael Marz,
You may want to have a look at a script which I have published on GeoNet recently:
The script uses the ArcGIS API for Python - with groups.search() and users.search() - to get an overview of group membership within an organization. It creates a matrix - users along the y-axis and groups along the x-axis - with a 1 or a 0 to indicate wether the user is a member of the group or not. This matrix is being written to a CSV file and can be imported to an Excel spreadsheet for further analysis.
Does this serve your needs?
BR,
Egge-Jan
Hello,
thank you for this script. It worked well, but my approach needs an array per group-membership. 🙂 So it helps, but my issue was a wrong user level.
The issue was, that this approach needs a Level 2 Named User.
Even if a level 1 named user has the rights to see all groups and members, it is not the same with the python api.
I tested the lines with a level 2 named user and it worked. The groups are returned as array.