【问题标题】:How to retrieve a Sharing Information object from SharePoint Online using CSOM?如何使用 CSOM 从 SharePoint Online 检索共享信息对象?
【发布时间】:2019-04-10 05:12:42
【问题描述】:

我正在使用 SharePoint 客户端对象模型在线登录 SharePoint,然后检索列表以获取 SharePoint 上的文档。然后我想获取这些文档的共享链接。这是我目前的做法:

using (var context = new ClientContext(siteURL))
{
     context.Credentials = new SharePointOnlineCredentials(login, securePassword);
     context.Load(context.Web, w => w.Title);
     context.ExecuteQuery();

     List docList = context.Web.Lists.GetByTitle("Documents");
     context.Load(docList);
     // This creates a CamlQuery that has a RowLimit of 100, and also specifies Scope="RecursiveAll"
     // so that it grabs all list items, regardless of the folder they are in.
     CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
     ListItemCollection items = docList.GetItems(query);

     // Retrieve all items in the ListItemCollection from List.GetItems(Query).
     context.Load(items);
     context.ExecuteQuery();
     foreach (ListItem listItem in items)
     {
          var sharingInfo = ObjectSharingInformation.GetListItemSharingInformation(
             context, docList.Id, listItem.Id, false, true, false, true, true, true);

          context.Load(sharingInfo);
          context.ExecuteQuery();
          string str = sharingInfo.AnonymousEditLink;
     }
}

这里的问题是sharingInfo 对象有一个名为 AnonymousEditLink 的字段,但它是一个空字符串。我不确定为什么这是一个空字符串。这是生成共享链接的正确方法吗?

我也试过这个(但没有用):

var sharingInfo = ObjectSharingInformation.GetObjectSharingInformation(
                    context, listItem, false, true, false, true, true, true, true);

我指的是这里显示的方法:https://sharepoint.stackexchange.com/questions/143612/how-to-retrieve-the-shared-link-of-a-file-programmatically

【问题讨论】:

  • 你有什么运气吗?当我提出请求时,即使它显示在 UI 中,它也不会显示域外的用户

标签: asp.net sharepoint sharepoint-online csom


【解决方案1】:

我一直在使用 GetListItemSharingInformation 进行一些工作/测试,一旦用户访问了通过电子邮件收到的链接,AnonymousEditLink 似乎就会被填充。

SharedWithUsersCollection 也是如此。本质上,一旦用户访问了链接。您会发现属性已填充。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多