<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to get all users belonging to my org in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070433#M6230</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a simple requirement, to list all users in my AGOL subscription. I have administrator role in my org's AGOL subscription. My org has more than 1000 users and I am using UserManager and advance_search to paginate. Example code below&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT color="#3366FF"&gt;um = UserManager(self.gis)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;current_user = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;# TODO: find best pattern to list only organizational users&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;# currently below code is listing every AGOL user&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;user_search_pattern = "access: org OR access: public OR access: private"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;users_searched = um.advanced_search(query=user_search_pattern, start=current_user, max_users=self.MAX_USERS, as_dict=True, return_count=False)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;while (len(users_searched['results']) &amp;gt; 0):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;current_user += len(users_searched['results'])&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; for user in users_searched['results']:&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; username = user['username']&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; user_details = self.get_user_details(username)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #TODO: Not sure this is correct logic to ascertain if user is a native AGOL org user&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # For now, use this logic&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if 'orgId' in user_details:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.org_users[username] = user_details['orgId']&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; # get next pageful users&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; users_searched = um.advanced_search(query=user_search_pattern,&lt;SPAN&gt;start=current_user, max_users=self.MAX_USERS)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT color="#3366FF"&gt;print("Total #{} organisational users found.".format(len(self.org_users)))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The above code is extremely slow. I am struggling to find correct &lt;STRONG&gt;query&lt;/STRONG&gt; parameter I should use. I have tried all different combinations, they all either give empty result or lists every AGOL user including those that do not belong to my org. If I go to my AGOL's organization page in browser, I have 1,309 users. Browser's Dev Tools tell me it runs url param "q=(*)" and pagination parameters. How do I get the same result using ArcGIS API for Python script?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vish&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Jun 2021 14:02:11 GMT</pubDate>
    <dc:creator>VishApte</dc:creator>
    <dc:date>2021-06-21T14:02:11Z</dc:date>
    <item>
      <title>How to get all users belonging to my org</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070433#M6230</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have a simple requirement, to list all users in my AGOL subscription. I have administrator role in my org's AGOL subscription. My org has more than 1000 users and I am using UserManager and advance_search to paginate. Example code below&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT color="#3366FF"&gt;um = UserManager(self.gis)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;current_user = 0&lt;/FONT&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;# TODO: find best pattern to list only organizational users&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;# currently below code is listing every AGOL user&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT color="#3366FF"&gt;user_search_pattern = "access: org OR access: public OR access: private"&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;users_searched = um.advanced_search(query=user_search_pattern, start=current_user, max_users=self.MAX_USERS, as_dict=True, return_count=False)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;while (len(users_searched['results']) &amp;gt; 0):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;current_user += len(users_searched['results'])&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; for user in users_searched['results']:&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; username = user['username']&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; user_details = self.get_user_details(username)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; #TODO: Not sure this is correct logic to ascertain if user is a native AGOL org user&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # For now, use this logic&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if 'orgId' in user_details:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.org_users[username] = user_details['orgId']&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; # get next pageful users&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#3366FF"&gt;&amp;nbsp; &amp;nbsp; users_searched = um.advanced_search(query=user_search_pattern,&lt;SPAN&gt;start=current_user, max_users=self.MAX_USERS)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-90px"&gt;&lt;FONT color="#3366FF"&gt;print("Total #{} organisational users found.".format(len(self.org_users)))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The above code is extremely slow. I am struggling to find correct &lt;STRONG&gt;query&lt;/STRONG&gt; parameter I should use. I have tried all different combinations, they all either give empty result or lists every AGOL user including those that do not belong to my org. If I go to my AGOL's organization page in browser, I have 1,309 users. Browser's Dev Tools tell me it runs url param "q=(*)" and pagination parameters. How do I get the same result using ArcGIS API for Python script?&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vish&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 14:02:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070433#M6230</guid>
      <dc:creator>VishApte</dc:creator>
      <dc:date>2021-06-21T14:02:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to get all users belonging to my org</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070453#M6231</link>
      <description>&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcgis

gis = GIS('https://www.arcgis.com', '', '')

user_list = gis.users.search(query = '*', max_users = 10000)
print(user_list)&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 21 Jun 2021 14:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070453#M6231</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-06-21T14:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to get all users belonging to my org</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070505#M6233</link>
      <description>&lt;P&gt;Does this code require a username and password?&lt;/P&gt;&lt;P&gt;Does the user need to be an administrator of the Portal for the script to run?&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 15:36:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070505#M6233</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-06-21T15:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get all users belonging to my org</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070818#M6241</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/167692"&gt;@DavidPike&lt;/a&gt;&amp;nbsp;, simple as that, it is embarrassing for me.&lt;/P&gt;&lt;P&gt;This script is reporting lot of properties and usage pattern for users. I felt need to use UserManager.advanced_search to support pagination. And UserManager.advanced_search(query="*",....) does not yield same result as&amp;nbsp;&amp;nbsp;UserManager.search(query="*")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VishApte_0-1624328674898.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/16558i5AE0CC050AADBE85/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VishApte_0-1624328674898.png" alt="VishApte_0-1624328674898.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Vish&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 02:26:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-get-all-users-belonging-to-my-org/m-p/1070818#M6241</guid>
      <dc:creator>VishApte</dc:creator>
      <dc:date>2021-06-22T02:26:33Z</dc:date>
    </item>
  </channel>
</rss>

