Thursday, 20 October 2016

Working with the CSOM External Sharing API in SharePoint Online

I was recently working on a SharePoint Online project where we had quite a heavy use of the External Sharing CSOM API.

Here are some utility functions I have put together which might be useful in the future.

I have used the SharePoint Online CSOM version 16.1.5626.1200 for this:
https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/16.1.5626.1200/

Also, there are some really nice samples in SharePoint Patterns and Practices (PnP) around External Sharing

1) Site Collection External Sharing

2) External Sharing Expiration Service

In my case however, I have used the native CSOM API methods for creating the utility functions.

1) Get Externally Shared Documents


This method uses search to get all documents which are externally shared. You can modify the search query to filter by site, site collection, document library etc.



2) Get external users for a document


This method uses the native CSOM API to get all the users with whom a particular document is shared.


3) Get all external users in a Site Collection:



4) Get all external users in a Tenant:


Hope this helps!

2 comments:

Matt said...

Thank you for you time helping us understand how to access SharePoint. I have a problem accessing an online sharepoint.com of a customer of mine. It appears that you are an expert in this area. Is there a forum to ask questions like this?

KS said...

Very nice article Vardhaman, Thanks for sharing :)
-Keval Solanki