<?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 Access and manage HUB user accounts in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219129#M7856</link>
    <description>&lt;P data-unlink="true"&gt;I'm attempting to &lt;A href="https://developers.arcgis.com/python/guide/accessing-and-managing-users/" target="_self"&gt;access and manage users&lt;/A&gt; in our HUB community account with the python API. I'm using our only sign-in credentials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis = GIS("https://countyhub.maps.arcgis.com", "username", "password")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the number of members I use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hub_users = gis.users.search()
number = len(hub_users)
number

#prints
100&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know where it gets the 100? Our Members page says we have 538 enabled members with any sort of role.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JaredPilbeam2_0-1665001902775.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52926iAE239EA2F54C494D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JaredPilbeam2_0-1665001902775.png" alt="JaredPilbeam2_0-1665001902775.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I attempt to gather some info with the search queries and I'm blocked by an Exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# anonymous connection to ArcGIS Online
ago_gis = GIS()
# # search the users whose email address ends with esri.com
esri_public_accounts = ago_gis.users.search(query='email = @esri.com')
len(esri_public_accounts)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Exception&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;: You do not have permissions to access this resource or perform this operation. (Error Code: 403)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Additionally, I've tried with my AGOL sign-in credentials. It also throws the same Exception with querying.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2022 21:08:55 GMT</pubDate>
    <dc:creator>JaredPilbeam2</dc:creator>
    <dc:date>2022-10-05T21:08:55Z</dc:date>
    <item>
      <title>Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219129#M7856</link>
      <description>&lt;P data-unlink="true"&gt;I'm attempting to &lt;A href="https://developers.arcgis.com/python/guide/accessing-and-managing-users/" target="_self"&gt;access and manage users&lt;/A&gt; in our HUB community account with the python API. I'm using our only sign-in credentials.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gis = GIS("https://countyhub.maps.arcgis.com", "username", "password")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the number of members I use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hub_users = gis.users.search()
number = len(hub_users)
number

#prints
100&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't know where it gets the 100? Our Members page says we have 538 enabled members with any sort of role.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JaredPilbeam2_0-1665001902775.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52926iAE239EA2F54C494D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JaredPilbeam2_0-1665001902775.png" alt="JaredPilbeam2_0-1665001902775.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then I attempt to gather some info with the search queries and I'm blocked by an Exception.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# anonymous connection to ArcGIS Online
ago_gis = GIS()
# # search the users whose email address ends with esri.com
esri_public_accounts = ago_gis.users.search(query='email = @esri.com')
len(esri_public_accounts)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Exception&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;: You do not have permissions to access this resource or perform this operation. (Error Code: 403)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Additionally, I've tried with my AGOL sign-in credentials. It also throws the same Exception with querying.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 21:08:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219129#M7856</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2022-10-05T21:08:55Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219182#M7857</link>
      <description>&lt;P&gt;Don't know if there is some kind of limit that it will return as I only have 92 members in my Org.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1665013082914.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52939iD045D3301B81F345/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_0-1665013082914.png" alt="RhettZufelt_0-1665013082914.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Which is exactly what your code reports:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_1-1665013121218.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52940i69F1F2377F2B50F4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_1-1665013121218.png" alt="RhettZufelt_1-1665013121218.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2022 23:39:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219182#M7857</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-05T23:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219355#M7862</link>
      <description>&lt;P&gt;I was thinking that may be the case. I'm not sure how to avoid that limit either. I put it in an if else statement, and it still was counting 100 or less. But I'm not sure how much you can trust that.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hub_users = gis.users.search()
number = len(hub_users)
if number &amp;gt;= 100:
    print('members exceed 100')
else:
    print('members are 100 or less')

#prints
members are 100 or less&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:44:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219355#M7862</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2022-10-06T14:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219362#M7863</link>
      <description>&lt;P&gt;This was bothering me so I added some users and tested again.&lt;/P&gt;&lt;P&gt;For whatever reason, it does appear that the results are limited to 100 users:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_0-1665067968188.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52974iF83488F3ABF53C8E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_0-1665067968188.png" alt="RhettZufelt_0-1665067968188.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RhettZufelt_1-1665067985479.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52975i935325B7482D4B25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RhettZufelt_1-1665067985479.png" alt="RhettZufelt_1-1665067985479.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 14:53:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219362#M7863</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-06T14:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219375#M7864</link>
      <description>&lt;P&gt;Interesting.&lt;/P&gt;&lt;P&gt;I may have made a mistake on my last test with the if else statement. I think I was signed in to my AGOL account. Just now, I made sure I was using Hub credentials and I get this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;hub_users = gis.users.search()
number = len(hub_users)
if number &amp;gt;= 100:
    print('members exceed 100')
else:
    print('members are 100 or less')

#prints
members exceed 100&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where to take it from here?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 15:16:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219375#M7864</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2022-10-06T15:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219396#M7865</link>
      <description>&lt;P&gt;Next I would change the &amp;gt;= to just &amp;gt; and see what it says (or look at value of number).&lt;/P&gt;&lt;P&gt;The code as is will say it exceed 100 even if it is equal to 100, so can't tell if you are still getting the same result of 100.&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2022 15:32:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219396#M7865</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-10-06T15:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: Access and manage HUB user accounts</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219568#M7868</link>
      <description>&lt;P&gt;Found out you have to utilize the&lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#usermanager" target="_self"&gt;&amp;nbsp;UserManager&lt;/A&gt; class (with admin privileges).&lt;/P&gt;&lt;P&gt;This will get you a list which includes the count of users in your org:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from itertools import count
import arcgis

users = arcgis.gis.UserManager(gis)

totalUsers = users.counts(type='user_type', as_df=False)
totalUsers
#prints
[{'key': 'creatorUT', 'count': 538}]

#index it to pull out the integer
totalUsers = users.counts(type='user_type', as_df=False)[0]['count']
totalUsers
#prints
538&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Credit goes to &lt;A href="https://gis.stackexchange.com/questions/339819/getting-all-users-in-arcgis-online-organization#answer-343106" target="_self"&gt;this SE answer&lt;/A&gt;. This answer has another useful line of code. It allows you to print out the names in a list.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;allUsers = users.search(query=None, max_users=totalUsers)
allUsers&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Oct 2022 19:50:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/access-and-manage-hub-user-accounts/m-p/1219568#M7868</guid>
      <dc:creator>JaredPilbeam2</dc:creator>
      <dc:date>2022-10-06T19:50:41Z</dc:date>
    </item>
  </channel>
</rss>

