Select to view content in your preferred language

Get new user types with python api for ArcGIS?

4240
4
Jump to solution
07-04-2019 12:05 AM
lxd
by
Regular Contributor

Hi,

I am doing reporting on our user types on ArcGIS Online. Recently AGOL changed user types from level 1 & level 2 to Creator, Editor, Viewer, etc as per screenshot below. 

new user types on AGOL

I can't find the right object (or property of an object) in ArcGIS API for Python to get these user types programically

.

All I get is our custom roles, levels (which are 1, 2 and 11 and nothing else) and user types (org_admin, org_publisher and org_users) which don't match the new user types. Has anyone worked out how to do it?

My current code is something like that:

for user in gis.users.search(max_users=500):
   try:
      name = user.username
      role = user.role
      ulevel = user.level
      firstname = user.firstName
      lastname = user.lastName
      last_login = user.lastLogin

      if hasattr(user, 'roleId'):
         for role in roles:
            if(user.roleId == role.role_id):
            role_name = role.name

   else:
      role_name = "undefined"
      diff_name = gis.users.get(name)

Tags (1)
1 Solution

Accepted Solutions
EarlMedina
Esri Regular Contributor

Hi Lidia,

The property you're looking for is userType. Valid values correspond to the userLicenseTypeId values described in REST API documentation:

creatorUT | editorUT | GISProfessionalAdvUT | GISProfessionalBasicUT | GISProfessionalStdUT | viewerUT | fieldWorkerUT

 https://developers.arcgis.com/rest/enterprise-administration/portal/create-user.htm

View solution in original post

4 Replies
EarlMedina
Esri Regular Contributor

Hi Lidia,

The property you're looking for is userType. Valid values correspond to the userLicenseTypeId values described in REST API documentation:

creatorUT | editorUT | GISProfessionalAdvUT | GISProfessionalBasicUT | GISProfessionalStdUT | viewerUT | fieldWorkerUT

 https://developers.arcgis.com/rest/enterprise-administration/portal/create-user.htm

lxd
by
Regular Contributor

Great! It's exactly what I was after! Thanks. 

0 Kudos
ChrisBeaudette
Frequent Contributor

When I run the code using user.userType, the only value returned from ArcGIS Enterprise v10.9.1 is 'arcgisonly'.  Using 'user.userLicenseTypeId' got me what I expected:  the four types associated with our User Types in our Enterprise portal: Creator, Editor, Mobile Worker, and Viewer.  

Would be great if userType and userLicenseTypeId were documented in the python API docs:  https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user

jorisfrenkel
Frequent Contributor

The best option seems to set the role AND the usertype AND the level when you create a new user. Otherwise the new member default get in your way and the user may either not be created or created with the wrong settings. This is not really clear in de documentation.

0 Kudos