Export List of Portal Users with specific role type

914
1
02-10-2022 12:51 AM
Labels (1)
KikSiops
New Contributor III

Hi,

I am trying to export list of all Portal Users with username, email, role, level, creation time, etc. 

I'm using ipynb in ArcGIS Pro and able to generate a csv file. However, I only have the User Level and the User Role, no User Type like(Viewer, Fieldworker and Creator) on the extracted reported.

Do you know the correct "keyword" to put on the script to have these details?

tried this below but only gives me : arcigsonly for the result.

'User_type': [usr:userType for usr in users],

this is the script I am using,

 

AprilKayemanojo_0-1644482220794.png

 

AprilKayemanojo_0-1644800611826.png

 

Thanks 🙂

0 Kudos
1 Reply
GaryBarden
New Contributor III

Hi, Wondering if you ever figured this out? I'm using the code below, but I can't figure out how I can limit my output to just one role (Role = Viewer). 

import csv
from arcgis.gis import GIS

gis = GIS("<Portal URL>", "<UserName>", "<Password>", verify_cert=False)

outputFile = r"<Output File Location>"

users = gis.users.search('*', max_users=15000)

with open(outputFile, 'w', newline='') as ResultFile:
wr = csv.writer(ResultFile)
header = 'Username', 'Role', 'Email'
wr.writerow(header)
for user in users:
UserRow = user.username, user.role, user.email
wr.writerow(UserRow)

0 Kudos