print out list of online members

1408
7
04-05-2019 09:07 AM
JasonRoper
New Contributor III

In an ArcGIS Online account, how do you simply print out a list of members and their Roles?  It would be a nice feature to add.

Tags (1)
7 Replies
AlexandraScott
Occasional Contributor

Hi Jason, 

There is not a built in way to do this, but there are free Admin tools from the ArcGIS Marketplace that can or you can use python. Examples and more information in the link below:

https://support.esri.com/en/technical-article/000012707 

JakeSkinner
Esri Esteemed Contributor

Hi Jason,

 

You can do this using the Python API.  Below is a sample:

 

from arcgis.gis import GIS
from arcgis.gis import RoleManager
import getpass
import csv, time

# Enter the URL to your ArcGIS Online Organization or Portal for ArcGIS
portalURL = 'https://countysandbox.maps.arcgis.com'
# Enter the username & password for an Administrator in your Organization
username = 'jskinner_CountySandbox'
password = '******'
outputFile = r'C:\temp\output.csv'

gis = GIS(portalURL, username, password)
allUsers = gis.users.search(max_users=1000)
print('Total Portal Users: ' + str(len(allUsers)))

with open(outputFile, 'w') as output:
    dataWriter = csv.writer(output, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
    # Write header row.
    dataWriter.writerow(['Full Name',
                         'Email',
                         'Username',
                         'Date Created',
                         'Role',
                         'Level',
                         'Last Login'])

    for user in allUsers:
        if user.role == 'org_admin':
            userRole = 'Administrator'
        elif user.role == 'org_publisher':
            userRole = 'Publisher'
        elif user.role == 'org_user':
            userRole = 'User'
        else:
            userRole = RoleManager(gis).get_role(user.role).name

        dataWriter.writerow([user['fullName'],
                             user['email'],
                             user['username'],
                             time.strftime("%Y-%m-%d",time.gmtime(user['created']/1000)),
                             userRole,
                             user['level'],
                             time.strftime("%Y-%m-%d",time.gmtime(user['lastLogin']/1000))])‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
BillChappell
Occasional Contributor II

Jake,

Wow, everything I was trying to do an more, and to top it off it ran on the first try. This should be listed in the help docs, that I've spent hours looking through.

Thanks, 

Bill

0 Kudos
CoryBowlin1
New Contributor

This is GREAT!!!! Works like a charm. Hopefully I can figure out how to use it with PKI authentication. We will be switching to it soon. 

0 Kudos
BlakeBilbo
Occasional Contributor

Hi Jason, 

This, and many other "not-supported" tasks can easily be achieved in the free version of Admin Tools for ArcGIS Online. Simply use the "Export Users to CSV" tool in the Users category of tools.

If you desire, you can even filter the list many different ways, and also pick and choose which supplemental fields you can export with them, as shown below in this screenshot:

User Fields to Export

Hope this helps, good luck!

JasonRoper
New Contributor III

Thanks for your help everyone.  

0 Kudos
Caroline-MR-Rose
New Contributor III

There is now an option to export a report (in .csv format) of an organization's members or of its items. It is available under Organization > Status > Reports > Create report. See details in this post: View and report status—ArcGIS Online Help | Documentation 

0 Kudos