You can use the portal service to search for users. This operation allows authenticated users to search for other members in the portal.
The portal search index is updated whenever users are created, updated, or deleted. The results from a search are limited to searching members that are visible to the portal. This is based on permissions, which members can manage by adjusting their access settings.
You can search for users based on:
- Keywords like names, usernames, and email addresses.
- Filtering specific criteria such as role, department, or location in a member profile.
- Wildcard characters (
*
or%
) search to narrow results based on patterns. - Attributes such as creation date, last login time or permissions.
Search parameters
The general steps to search for users are:
- Define the URL to the portal service:
https
.://www.arcgis.com/sharing/rest/community/users - Provide the text for your search. For example,
username
orfull
.Name - Set the sort order for your return results.
- Any additional fields, such as description, tags, created or modified.
URL request
https://www.arcgis.com/sharing/rest/community/users?<parameters>
Default fields
When searching for text in items or groups, if you do not provide fields, the following default fields are searched.
Items | Groups |
---|---|
title | title |
tags | tags |
description | description |
snippet | snippet |
tagKeywords | owner |
Key parameters
Name | Description | Examples |
---|---|---|
q | The text or formatted query with text. | q="streets" q="john+smith" q=(firstName:"john" OR lastName:"smith") |
filter | Apply structured filtering using field name. | filter=first filter=last |
sort | The primary sort field. | sortField=username sortField=created sortField=modified sortField=fullname |
sort | Return results in ascending or descending order. | sortOrder=asc sortOrder=desc |
Query structure
Here are a some of the general rules for formatting queries:
- For an open search, specify the text at the beginning. e.g.
q="john+smith"
- To search specific fields, use a colon
:
after the field name. - Use double quotes
"text"
around all user search text. - Capitalize all
AND
,OR
, andNOT
operators. - Use
()
to group operators.
For example:
https://www.arcgis.com/sharing/rest/community/users?f=json&q="john"
Code examples
Search for a user by username
Find users with the keyword username.
search_username = "desired_username"
# Search for users by username
user_results = gis.users.search(search_username)
# Print the results
for user in user_results:
print("Username:", user.username)
print("Full Name:", user.fullName)
print("Email:", user.email)
print("Account Type:", user.userType)
print("Role:", user.role)
Search for users by email
Find users with the keyword user's email.
email = "example@email.com"
# Search for users by email
user_search = gis.users.search(email=email)
# Iterate through search results
for user in user_search:
print("Username:", user.username)
print("Full Name:", user.fullName)
print("Email:", user.email)
print("Role:", user.role)
print("User Type:", user.userType)
print("Account Level:", user.level)
Search for users by full name
Find users by full name using the keyword user's name.
full_name = "John Doe"
# Perform the search
search_results = gis.users.search(full_name)
# Print search results
for user in search_results:
print("Username:", user.username)
print("Full Name:", user.fullName)
print("Email:", user.email)
print("Role:", user.role)
Search for users by user type
Find users based on specific user types.
user_type = "creator" # Replace with the desired user type
# Search for users by user type
search_results = gis.users.search(query="userType:" + user_type)
# Print the search results
for user in search_results:
print("Username:", user.username)
print("Full Name:", user.fullName)
print("Email:", user.email)
print("User Type:", user.userType)
Search for users by specific group
Find users based on specific group names.
# Define the list of group names to search for
group_names = ['Group1', 'Group2', 'Group3']
# Empty list to store matching users
matching_users = []
# Loop through each group name
for group_name in group_names:
# Retrieve the group object by name
# Assuming there is only one group with the specified name
group = gis.groups.search(group_name)[0]
# Retrieve the users who are members of the group
group_users = group.get_members()
# Add users to the matching_users list
matching_users.extend(group_users)
Tools
Use tools to access the portal and create and manage content for applications.
ArcGIS Enterprise
Create, manage, analyze, and share data, maps, and applications in your organization.
Portal
Create, manage, and access content and data services for applications.
Map Viewer
Create, explore, and share web maps for 2D applications.
Scene Viewer
Create, style, and explore web scenes.
Vector Tile Style Editor
Create styles for basemap and vector tile layers.
Content management tools
Create, manage, organize, and share items in a portal.
Data management tools
Import data and create hosted layers and data services. Upload and manage documents, images, and other files.
Spatial analysis tools
Perform feature and raster analysis to create new datasets with the Map Viewer.
Developer credentials tool
Create API key and OAuth 2.0 developer credentials for custom applications.
Items
Manage and share items.
ArcGIS Pro
Create, style, and explore maps and scenes.
Geoprocessing tools
Import, manage, and analyze data.