ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Core Namespace / ArcGISPortalExtensions Class / GetGroupsFromUserAsync Method
The user whose community information will be queried
Example Version

GetGroupsFromUserAsync Method
Gets the groups from the user's community information.
Syntax
public static Task<IReadOnlyList<PortalGroup>> GetGroupsFromUserAsync( 
   ArcGISPortal portal,
   string username
)

Parameters

portal
username
The user whose community information will be queried

Return Value

Exceptions
ExceptionDescription
Thrown when an invalid portal is provided as the active portal.
username cannot be null or empty.
You do not have permissions to access this resource or perform this operation.
Request failed: status code {status code}.
Remarks
Executes the following portal rest query:
{portalURL}sharing/rest/community/users/{userName}

Groups of the user are returned only to the user or the administrator of the user's organization. A user is not visible to any other user (except the organization's administrator) if their access setting is set to "private".
Example
Portal: Get the groups for the specified user
//elsewhere...
//var owner = portal.GetSignOnUsername();
var groups = await portal.GetGroupsFromUserAsync(owner);
foreach (var group in groups)
{
  //Do something with the portal groups
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also