Nevermind! Got it:
http://www.arcgis.com/sharing/rest/community/users/jsmith
Feel free to mark this question as answered, even if you provided the answer yourself.
Here's another way with python
from arcgis.gis import GIS gis = GIS("https://<your portal URL>/portal", "<your username>","<your password>") oneUser = gis.users.search("<username>") for i in oneUser: print(i.groups) # or you can get multiple users# myUsers = gis.users.search("*")# then list the groups for those users# for i in myUsers :# print(i.username, " ", i.groups) # see https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#user # for other things you can print out for each user # see https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#usermanager # for ways to search and sort users
I was wondering if you need to be logged in under an admin account to access all groups for a list of users? My current script is throwing an error when I try to list user.groups. Am I missing something?
Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 6675, in __getitem__
return dict.__getitem__(self, k)
KeyError: 'groups'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 6856, in groups
return [Group(self._gis, group['id']) for group in self['groups']]
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 6679, in __getitem__
return dict.__getitem__(self, k)
KeyError: 'groups'
Code:
#total number of users in AGOL
totalUsers = users.counts('user_type', as_df=False)[0]['count']
allUsers = users.search(query=None, max_users=totalUsers)
for user in allUsers:
if user.lastLogin != -1:
print (user.fullName, ",", user.idpUsername, ",", user.id, ",", user.groups, ",", user.storageUsage, ",", user.storageQuota, ",", datetime.datetime.fromtimestamp(user.created/1000).strftime('%Y-%m-%d'), ",", datetime.datetime.fromtimestamp(user.lastLogin/1000).strftime('%Y-%m-%d'))
Hi Pierre Masson,
Another way to do this is to find who has the Portal Admin access, they will be able to go through the Organization
tab choose manage members, find the Individual's name, next to their name is three dots ... , click that and in the drop down choose view groups.
This may be an easier process in future.
Kind Regards
Keiren