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

In This Topic
    GetGroupsFromUserAsync Method
    In This Topic
    Gets the groups from the user's community information.
    Syntax
    public static Task<IReadOnlyList<PortalGroup>> GetGroupsFromUserAsync( 
       ArcGISPortal portal,
       string username
    )
    Public Shared Function GetGroupsFromUserAsync( _
       ByVal portal As ArcGISPortal, _
       ByVal username As String _
    ) As Task(Of IReadOnlyList(Of PortalGroup))

    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