forked from Esri/ago-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateUserListCSV.py
22 lines (19 loc) · 993 Bytes
/
createUserListCSV.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Requires admin role.
import csv, time
from agoTools.admin import Admin
agoAdmin = Admin(<username>) # Replace <username> with your admin username.
users = agoAdmin.getUsers()
outputFile = 'c:/temp/users.csv'
with open(outputFile, 'wb') as output:
dataWriter = csv.writer(output, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
# Write header row.
dataWriter.writerow(['Full Name', 'Email', 'Username', 'Role', 'Date Created'])
# Write user data.
for user in users:
if user: #comment out this line if using one of the filters below
# examples of how to filter users in various ways...
# if user['disabled'] == True:
# if user['username'] == '<username>':
# if 'Mark' in user['fullName']:
# if '@agencyX.gov' in user['email']:
dataWriter.writerow([user['fullName'], user['email'], user['username'], user['role'], time.strftime("%Y-%m-%d",time.gmtime(user['created']/1000))])