Export gis.user.groups from portal

917
2
06-12-2019 06:31 AM
ShukwaunCheung
New Contributor

Hi everbody,

I want to export from gis.user.search() the json array "groups".

Here some Information about the "groups": arcgis.gis module — arcgis 1.6.1 documentation 

How can I see the groups from user?

Thanks .

from arcgis.gis import GIS
import arcgis
import json

gis = GIS("url_to_portal", "admin_user", "password")

user_accounts = gis.users.search()
group = gis.groups.search()

for user in (str(user_accounts.groups)):
    liste = {}
    user = json.loads(user_accounts.groups)
    print (user)
   
else:
    print("isn't working so far")
	
	
	
#Error Msg
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-18-57b3d16d2703> in <module>
     19 
---> 20 for user in (str(user_accounts.groups)):
     21     liste = {}

AttributeError: 'list' object has no attribute 'groups'‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
2 Replies
Egge-JanPollé1
MVP Regular Contributor

Hi Shukwaun Cheung‌,

You might have a look at a Python script which I have published here:

https://community.esri.com/people/EPolle_TensingInternational/blog/2019/03/21/a-quick-overview-of-gr... 

Does this serve your purposes?

Cheers,

Egge-Jan

ShukwaunCheung
New Contributor

Hi Egge-Jan Pollé,

thank you for your help.
I was able to create a CSV with help of your script, in which I could see the users with all available groups. Each user had a zero as a result for each group, which means that this user is not in this group. Later I invited a user to a group, I got a one in the whole table as result. I know that there should be serveral ones. :\
My aim was to list each user's groups in a column with a comma as seperater.

What I got:

What I got

What I want:

Whats I want

some Ideas?

0 Kudos