<?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 Re: List of All Portal Users in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/1045101#M5907</link>
    <description>&lt;P&gt;This solution only gets you the first 100 users. I used advanced_search to get more users, but I believe there is still a maximum. If you reach the maximum you have to use paging.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But how did you figure out what the right search query was?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
source_users = source.users.advanced_search(query='!esri_ &amp;amp; !portaladmin', max_users = -1)
for user in source_users.get('results'):
    print(user.username)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my solution with paging. It works, but I'm not an Python expert, so I'm not sure this is the best method. It searches for 100 users at a time. When there are less than 100 users in the result, it means it has reached the last page.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
start = 0
lenght_searchresult = 100
while lenght_searchresult == 100:
    source_users = source.users.advanced_search(query='!esri_ &amp;amp; !portaladmin', start = start, max_users = 100)
    list_users = source_users.get('results')
    lenght_searchresult = len(list_users)
    start = start + 100
    for user in list_users:
        print(user.username)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 15:42:58 GMT</pubDate>
    <dc:creator>LaurensGIS</dc:creator>
    <dc:date>2021-04-08T15:42:58Z</dc:date>
    <item>
      <title>List of All Portal Users</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785752#M1362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to delete all the Users from a particular Group on my Portal.&amp;nbsp; I initially attempted a group first approach but realized that there wasn't an efficient way to access the users via the group.&amp;nbsp; Therefore, I took a user approach.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logic for &lt;A _jive_internal="true" href="https://community.esri.com/message/845066-users-search-by-group-name"&gt;identifying the users group&lt;/A&gt; and deleting the users is working however, I have yet to find a way to iterate through all of the portal users.&amp;nbsp; The search either times out or returns the errors below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/483382_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know it has something to do with the query but I have yet to find adequate search query documentation for the Python API.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/search.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/search.htm"&gt;Search—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm" title="https://developers.arcgis.com/rest/users-groups-and-items/search-reference.htm"&gt;Search reference—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone please point me in the direction of the correct user search syntax or assist with troubleshooting this issue?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 16:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785752#M1362</guid>
      <dc:creator>JosephRoberts2</dc:creator>
      <dc:date>2020-02-26T16:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: List of All Portal Users</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785753#M1363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.esri.com/migrated-users/389747"&gt;Joseph Roberts&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you seen this document: &lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/accessing-and-managing-groups/#Listing-users-belonging-to-a-group" title="https://developers.arcgis.com/python/guide/accessing-and-managing-groups/#Listing-users-belonging-to-a-group"&gt;Accessing and managing groups | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has a get_members function that will give you a list of users. From there you can delete the users.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;EM&gt;If this answer has helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Feb 2020 23:59:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785753#M1363</guid>
      <dc:creator>BenTurrell</dc:creator>
      <dc:date>2020-02-26T23:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: List of All Portal Users</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785754#M1364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is some code to iterate through users within Portal:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;source &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"https://servername.domain.com/portal"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"username"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"password"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; verify_cert&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
source_users &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; source&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;users&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'!esri_ &amp;amp; !portaladmin'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; user &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; source_users&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
       &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;user&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;username&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/785754#M1364</guid>
      <dc:creator>WilliamCraft</dc:creator>
      <dc:date>2021-12-12T08:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: List of All Portal Users</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/1045101#M5907</link>
      <description>&lt;P&gt;This solution only gets you the first 100 users. I used advanced_search to get more users, but I believe there is still a maximum. If you reach the maximum you have to use paging.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;But how did you figure out what the right search query was?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
source_users = source.users.advanced_search(query='!esri_ &amp;amp; !portaladmin', max_users = -1)
for user in source_users.get('results'):
    print(user.username)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my solution with paging. It works, but I'm not an Python expert, so I'm not sure this is the best method. It searches for 100 users at a time. When there are less than 100 users in the result, it means it has reached the last page.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;source = GIS("https://servername.domain.com/portal", "username", "password", verify_cert=False)
start = 0
lenght_searchresult = 100
while lenght_searchresult == 100:
    source_users = source.users.advanced_search(query='!esri_ &amp;amp; !portaladmin', start = start, max_users = 100)
    list_users = source_users.get('results')
    lenght_searchresult = len(list_users)
    start = start + 100
    for user in list_users:
        print(user.username)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 15:42:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/list-of-all-portal-users/m-p/1045101#M5907</guid>
      <dc:creator>LaurensGIS</dc:creator>
      <dc:date>2021-04-08T15:42:58Z</dc:date>
    </item>
  </channel>
</rss>

