2

Hello fellow colleagues,

I am starting to write a SharePoint Adapter which should work on: support SharePoint 2016 On-Premise/ Online and 365. So far I've understood that Office365 uses Online so it narrows down the supported version to: SharePoint 2016 On-Premise and SharePoint Online.

I found two different APIs for each supported version:

As per the information (https://dev.office.com/blogs/using-correct-csom-version-for-sharepoint-customizations) If you can guarantee that your code does not touch properties which have not been enabled in on-premises version, you can theoretically use SharePoint Online CSOM with on-premises as well. My user stories seems pretty staightforward: CRUD operations for file&folder, checkout/overrive/download/checkout.

My question: Will I be able to satisfy my straightforward user stories on both OnPremise and Online server using Microsoft.SharePointOnline.CSOM ? I was unable to find any information or some comparison mapping table between On-Premise and Online.

If any additional information is requred let me know.

Best Regards, SVG

  • For your requirements you will be able get away with using `Microsoft.SharePointOnline.CSOM` for both. I have a provisioning solution which I use for OnPrem and Online and I only use `Microsoft.SharePointOnline.CSOM`. However, you will need to handle authentication differently. I can post a solution for this if you need one – groveale Nov 22 '17 at 15:45
  • @groveale , thanks for sharing your observation. It will be much appreciated if you could share the authentication handling. I've done something similar for MS Exchange Adapter, but in SharePoint might be different. Thank you in advance! – Svetoslav Georgiev Nov 23 '17 at 08:54
  • @groveale , sorry for disturbing you again, but will this Microsoft.SharePointOnline.CSOM suitable for cross domain environments? I found very old article [CSOM_CrossDomain](https://sharepoint.stackexchange.com/questions/83135/sharepoint-2013-app-access-cross-site-collections) which asserts the opposite. Could you please share you thoughts. – Svetoslav Georgiev Nov 28 '17 at 07:38

1 Answers1

2

As per comments above, for your requirements you will be able to use Microsoft.SharePointOnline.CSOM for both OnPrem and Online CSOM code. As they both make use of the same Microsoft.SharePoint.Client namespace.

One key difference being how you populate the credentials property of your ClientContext object. Simple example below:

ClientContext cc = new ClientContext(siteUrl);

if (siteUrl.Contains("sharepoint.com"))
{
    // spo email e.g. alex@groveale.onmicrosoft.com
    cc.Credentials = new SharePointOnlineCredentials(username, password);
}
else
{
    // domain login e.g. "groveale/alex"
    cc.Credentials = new NetworkCredential(username, password);
}

If your OnPrem URLs contain sharepoint.com you will need another method of detecting if Online or OnPrem.

Note - You will need to ensure that the client components SDK is up-to-date on your farm. Otherwise you may find that some of the endpoints are not available.

groveale
  • 467
  • 3
  • 11