Select to view content in your preferred language

audit sharing for all portal items

868
5
Jump to solution
06-06-2022 04:05 PM
forestknutsen1
MVP Regular Contributor

Is it possible to  audit the sharing level for every item in portal without browsing to each item? Perhaps with the rest API?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It could be easy enough with the Python API.

import arcgis

gis = arcgis.GIS('your url', 'user', 'password')

items = gis.content.search('-owner:esri -owner:esri_apps', max_items=-1)

for i in items:
    print(i.title, i.shared_with)

 

If you like, you could have this write to a text file instead of simply printing each line, but this should give you a good starting point.

- Josh Carlson
Kendall County GIS

View solution in original post

5 Replies
Brian_Wilson
Honored Contributor

Yes, sharing information is exposed in the REST api and I have done complete inventories of my site with the Python API.

 

jcarlson
MVP Esteemed Contributor

It could be easy enough with the Python API.

import arcgis

gis = arcgis.GIS('your url', 'user', 'password')

items = gis.content.search('-owner:esri -owner:esri_apps', max_items=-1)

for i in items:
    print(i.title, i.shared_with)

 

If you like, you could have this write to a text file instead of simply printing each line, but this should give you a good starting point.

- Josh Carlson
Kendall County GIS
Brian_Wilson
Honored Contributor

Comment on @jcarlson's elegant query.

That "everything but esri" query is critical, otherwise you will get hundreds of useless-to-you results back that are from the Esri catalog. The default max_items is 500 and without the query string you will always get back 500 items. I found that very confusing at first.

 

forestknutsen1
MVP Regular Contributor

That did it all right! Thanks @Brian_Wilson  and @jcarlson.

I also needed to exclude the esri_nav user from the search. 

0 Kudos
jcarlson
MVP Esteemed Contributor

I think you're allowed to delete the esri_nav stuff, aren't you? It's just the other two that you're stuck with. I seem to recall removing all those, hence the omission from my query.

- Josh Carlson
Kendall County GIS
0 Kudos