HOW TO
By default, maps, layers, and other items added or published to ArcGIS Online or the ArcGIS Enterprise portal are only accessible to the owner. The sharing level can be viewed by opening the services individually or from the Content tab. However, this process can be automated using ArcGIS API for Python. Follow the workflow described in this article to identify the sharing levels of all items owned by a specific user in ArcGIS Online or the ArcGIS Enterprise portal.
from arcgis.gis import GIS
#For ArcGIS Online
gis = GIS('https://arcgis.com', '<username>', '<password>')
#For the ArcGIS Enterprise portal
gis = GIS('https://<machine>.<domain>.com:7443/arcgis', 'Username', 'Password', verify_cert=False)
print ('Connected')
items = gis.content.search ('owner:<Owner_Name>', max_items=-1)
#For Python version 2.3 and prior
for file in items: print (file.title, file.shared_with)
#For Python version 2.4
for file in items:
print (file.title, file.sharing.shared_with)
The code block below demonstrates the full script in the ArcGIS Enterprise portal with Python version 2.4.
from arcgis.gis import GIS
gis = GIS('https://testdomain.esri.com:7443/arcgis', 'username', 'password', verify_cert=False)
print('Connected')
items = gis.content.search('owner:Owner123', max_items=-1)
for i in items:
print(i.title, i.sharing.shared_with)
Article ID: 000027939
Get help from ArcGIS experts
Start chatting now