<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export List of Groups, Users, Roles in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238839#M1192</link>
    <description>&lt;P&gt;Shouldn't be too hard, though somewhat annoyingly, a group's&amp;nbsp;&lt;STRONG&gt;get_members&lt;/STRONG&gt; method only returns strings. Personally, I can't get&amp;nbsp;&lt;STRONG&gt;user_list&lt;/STRONG&gt; to return anything.&lt;/P&gt;&lt;P&gt;If we query the users separately, we can merge them in using&amp;nbsp;&lt;STRONG&gt;pandas&lt;/STRONG&gt;.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;mport pandas as pd
from arcgis import GIS

gis = GIS('your url')

# groups
grps = gis.groups.search(max_groups=10000)

grp_list = []

for g in grps:
    for u in g.get_members()['users']:
        grp_list.append({'group':g.title, 'user':u})

g_df = pd.DataFrame(grp_list)

#users
users = gis.users.search(max_users=10000)

user_list = []

for u in users:
    user_list.append({'user':u.username, 'role':u.role})

u_df = pd.DataFrame(user_list)

# output merged doc
g_df.merge(u_df, on='user', how='left').to_csv('group_users.csv')&lt;/LI-CODE&gt;&lt;P&gt;The resulting CSV will list every unique group/user combination, complete with their role.&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 18:10:45 GMT</pubDate>
    <dc:creator>jcarlson</dc:creator>
    <dc:date>2022-12-07T18:10:45Z</dc:date>
    <item>
      <title>Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238790#M1186</link>
      <description>&lt;P&gt;I am looking for a python script that I can modify to export a csv file that shows all the groups, their users and their role.&amp;nbsp; Any examples out there?&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:33:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238790#M1186</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2022-12-07T16:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238792#M1187</link>
      <description>&lt;P&gt;Update deleted text&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:53:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238792#M1187</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2022-12-07T16:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238805#M1188</link>
      <description>&lt;P&gt;I can do this and get a list of Groups (id, isFav, isInvitationOnly, owner) for a specific user using the GROUPS Object.&lt;/P&gt;&lt;P&gt;But &lt;U&gt;&lt;STRONG&gt;how&lt;/STRONG&gt;&lt;/U&gt;&amp;nbsp;do I&amp;nbsp;get a list of users and their roles from this Group Object?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    esri_owned_groups = gis.groups.search('title:water', max_groups=maxResults)

    esri_group1 = esri_owned_groups[0]
    esri_group1.access


    print(esri_group1.groupid, esri_group1.isFav, esri_group1.isInvitationOnly)
    print(esri_group1.owner)
    time.localtime(esri_group1.created/1000)&lt;/LI-CODE&gt;&lt;UL&gt;&lt;LI&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 07 Dec 2022 16:52:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238805#M1188</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2022-12-07T16:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238817#M1189</link>
      <description>&lt;P&gt;OK I can get a list of all the groups and a few parameters...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have to now query the GROUP itself to now get the users and their role in the GROUP?&lt;/P&gt;&lt;P&gt;Not sure how to bridge this to get the users and roles in the group....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;Group title:"2011-2016 Dill" owner:useremail@test_VDOT&amp;gt;&lt;BR /&gt;5dc183991e97414retygdf1886474ea2&lt;BR /&gt;False&lt;BR /&gt;False&lt;BR /&gt;2011-2016 Dill&lt;BR /&gt;useremail@test_VDOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    esri_owned_groups = gis.groups.search(max_groups=1)
    
    counter = 0
    for group in esri_owned_groups:
        
        groupInfo = esri_owned_groups[counter]
        print(groupInfo)
        print(groupInfo.groupid)
        print(groupInfo.isFav)
        print(groupInfo.isInvitationOnly)
        print(groupInfo.title)
        print(groupInfo.owner)
       
        counter +=1        
    print("There are " + str(counter) + " roles")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238817#M1189</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2022-12-07T17:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238822#M1190</link>
      <description>&lt;P&gt;Once you have the group object, I think you can use the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#group" target="_self"&gt;user_list()&lt;/A&gt; method to get&amp;nbsp;a dictionary listing users and owners for the group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;esri_owned_groups = gis.groups.search(max_groups=1)

for group in esri_owned_groups:
    print(group)
    print(group.groupid)
    print(group.isFav)
    print(group.isInvitationOnly)
    print(group.title)
    print(group.owner)
    
    print(group.user_list())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:46:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238822#M1190</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2022-12-07T17:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238830#M1191</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/608938"&gt;@BlakeTerry&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:55:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238830#M1191</guid>
      <dc:creator>kapalczynski</dc:creator>
      <dc:date>2022-12-07T17:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Export List of Groups, Users, Roles</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238839#M1192</link>
      <description>&lt;P&gt;Shouldn't be too hard, though somewhat annoyingly, a group's&amp;nbsp;&lt;STRONG&gt;get_members&lt;/STRONG&gt; method only returns strings. Personally, I can't get&amp;nbsp;&lt;STRONG&gt;user_list&lt;/STRONG&gt; to return anything.&lt;/P&gt;&lt;P&gt;If we query the users separately, we can merge them in using&amp;nbsp;&lt;STRONG&gt;pandas&lt;/STRONG&gt;.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;mport pandas as pd
from arcgis import GIS

gis = GIS('your url')

# groups
grps = gis.groups.search(max_groups=10000)

grp_list = []

for g in grps:
    for u in g.get_members()['users']:
        grp_list.append({'group':g.title, 'user':u})

g_df = pd.DataFrame(grp_list)

#users
users = gis.users.search(max_users=10000)

user_list = []

for u in users:
    user_list.append({'user':u.username, 'role':u.role})

u_df = pd.DataFrame(user_list)

# output merged doc
g_df.merge(u_df, on='user', how='left').to_csv('group_users.csv')&lt;/LI-CODE&gt;&lt;P&gt;The resulting CSV will list every unique group/user combination, complete with their role.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 18:10:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/export-list-of-groups-users-roles/m-p/1238839#M1192</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-12-07T18:10:45Z</dc:date>
    </item>
  </channel>
</rss>

