Select to view content in your preferred language

Get users and Their Role and UserType

6744
10
12-20-2022 01:20 PM
kapalczynski
Frequent Contributor

I am trying to query for all my users and get their email, Role and UserType

 

item.usertype does not exist

item.role returns something that is not what I am expecting

Role
org_user
org_user
org_user
org_user
org_admin

org_user

 

 

I am expecting the name of my Roles as seen below... they are custom roles and I need that to eventually set them up..

kapalczynski_0-1671571165350.png

 

How do I get the UserName, UserType, UserRole, UserEmail???

 

user_list = gis.users.search(query=search_user, max_users=200)

with open(output_csv, 'w', encoding='utf-8') as file:
    csvfile = csv.writer(file, delimiter=',', lineterminator='\n')
    csvfile.writerow(["Name",                         # these are the headers; modify according to whatever properties you want in your report
                      "Role",
                      "UserType",
                      "Email"
                    ])

    for item in user_list: 
        csvfile.writerow([item.username,          # modify according to whatever properties you want in your report
                          item.role,
                          item.usertype,
                          item.email
                          ])

 

 

0 Kudos
10 Replies
VickyWang_COM
Occasional Contributor
users = gis.users.search(query="", max_users=10000, outside_org=False)
for user in users:
    username=user.username
    email=user.email
   userType=user.userType
    userLicenseType=user.userLicenseTypeId
    userRole=user.role
 
userType=> ""
userLicenseTypeId => GISProfessionalStdUT or CreatorUT
role => org_Publiser or org_Viewer

 

0 Kudos