Retrieving All Maps Available to a User

152
1
Jump to solution
05-20-2020 02:41 PM
CharlesRakaczky
New Contributor

Is it possible to retrieve the set of maps a particular user has access to within their organization? I would like to have a user sign in to my app, then populate a list with all the maps they have access to within the organization.

0 Kudos
1 Solution

Accepted Solutions
JoeHershman
MVP Regular Contributor

I find it a little convoluted.  But you need to get the Groups a user is in, and then from there all the PortalItems in those groups

private async Task<IEnumerable<PortalItem>> GetWebMaps(ArcGISPortal portal)
{
var groups = portal.User.Groups;
var usersMaps = new List<PortalItem>();

foreach (var portalGroup in groups)
{
var parameters = PortalQueryParameters.CreateForItemsOfTypeInGroup(PortalItemType.WebMap, portalGroup.GroupId);
parameters.Limit = 50;

var portalItems = (await portal.FindItemsAsync(parameters)).Results;

usersMaps.AddRange(portalItems);
}

return usersMaps;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

1 Reply
JoeHershman
MVP Regular Contributor

I find it a little convoluted.  But you need to get the Groups a user is in, and then from there all the PortalItems in those groups

private async Task<IEnumerable<PortalItem>> GetWebMaps(ArcGISPortal portal)
{
var groups = portal.User.Groups;
var usersMaps = new List<PortalItem>();

foreach (var portalGroup in groups)
{
var parameters = PortalQueryParameters.CreateForItemsOfTypeInGroup(PortalItemType.WebMap, portalGroup.GroupId);
parameters.Limit = 50;

var portalItems = (await portal.FindItemsAsync(parameters)).Results;

usersMaps.AddRange(portalItems);
}

return usersMaps;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post