简体   繁体   English

适用于2016内部部署和在线的SharePoint API

[英]SharePoint API for both 2016 On-Premise and Online

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. 我开始写一个应该能工作的SharePoint适配器:支持SharePoint 2016本地/在线和365。到目前为止,我了解Office365使用在线,因此将支持的版本缩小为:SharePoint 2016本地和SharePoint线上。

I found two different APIs for each supported version: 对于每个受支持的版本,我发现了两个不同的API:

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. 根据信息( https://dev.office.com/blogs/using-correct-csom-version-for-sharepoint-customizations ),如果您可以保证您的代码不涉及未在on-on中启用的属性,前提版本,理论上您也可以在本地使用SharePoint Online CSOM。 My user stories seems pretty staightforward: CRUD operations for file&folder, checkout/overrive/download/checkout. 我的用户故事似乎很简单:文件和文件夹的CRUD操作,签出/覆盖/下载/签出。

My question: Will I be able to satisfy my straightforward user stories on both OnPremise and Online server using Microsoft.SharePointOnline.CSOM ? 我的问题:我可以使用Microsoft.SharePointOnline.CSOM在OnPremise和Online服务器上满足我直截了当的用户故事吗? 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 最好的问候,SVG

As per comments above, for your requirements you will be able to use Microsoft.SharePointOnline.CSOM for both OnPrem and Online CSOM code. 根据上面的注释, 对于您的要求,您将可以将Microsoft.SharePointOnline.CSOM用于OnPrem和Online CSOM代码。 As they both make use of the same Microsoft.SharePoint.Client namespace. 因为它们都使用相同的Microsoft.SharePoint.Client命名空间。

One key difference being how you populate the credentials property of your ClientContext object. 一个主要区别是如何填充ClientContext对象的凭据属性。 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. 如果您的OnPrem URL包含sharepoint.com ,则将需要另一种检测Online或OnPrem的方法。

Note - You will need to ensure that the client components SDK is up-to-date on your farm. 注意 -您将需要确保客户端组件SDK在您的服务器场上是最新的。 Otherwise you may find that some of the endpoints are not available. 否则,您可能会发现某些端点不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM