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.
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
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">async</SPAN> Task<SPAN class="operator token"><</SPAN>IEnumerable<SPAN class="operator token"><</SPAN>PortalItem<SPAN class="operator token">></SPAN><SPAN class="operator token">></SPAN> <SPAN class="token function">GetWebMaps</SPAN><SPAN class="punctuation token">(</SPAN>ArcGISPortal portal<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> groups <SPAN class="operator token">=</SPAN> portal<SPAN class="punctuation token">.</SPAN>User<SPAN class="punctuation token">.</SPAN>Groups<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> usersMaps <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">List</SPAN><SPAN class="operator token"><</SPAN>PortalItem<SPAN class="operator token">></SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">foreach</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> portalGroup <SPAN class="keyword token">in</SPAN> groups<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">var</SPAN> parameters <SPAN class="operator token">=</SPAN> PortalQueryParameters<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateForItemsOfTypeInGroup</SPAN><SPAN class="punctuation token">(</SPAN>PortalItemType<SPAN class="punctuation token">.</SPAN>WebMap<SPAN class="punctuation token">,</SPAN> portalGroup<SPAN class="punctuation token">.</SPAN>GroupId<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> parameters<SPAN class="punctuation token">.</SPAN>Limit <SPAN class="operator token">=</SPAN> <SPAN class="number token">50</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> portalItems <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">await</SPAN> portal<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindItemsAsync</SPAN><SPAN class="punctuation token">(</SPAN>parameters<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>Results<SPAN class="punctuation token">;</SPAN> usersMaps<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddRange</SPAN><SPAN class="punctuation token">(</SPAN>portalItems<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">return</SPAN> usersMaps<SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.