读取SharePoint Online跨站点集合中的SharePoint列表

问题描述 投票:0回答:1

我有一个功能可以在提供程序托管的应用程序中运行(使用C#编写并使用CSOM),并可以访问SharePointOnline租户上的列表。

只要我从创建列表的网站集中访问提供者托管的应用程序,该功能就可以正常工作。

public bool CanUserReadList(ClientContext context, string listId)
    {
        try
        {                
            if (string.IsNullOrWhiteSpace(listId)) return false;

            List list = context.Web.Lists.GetById(new Guid(listId));                                                             
            context.Load(list, a => a.EffectiveBasePermissions,a=> a.DefaultViewUrl);
            context.ExecuteQuery();
            return list.EffectiveBasePermissions.Has(PermissionKind.OpenItems);
        }
        catch (Exception e)
        {
            //Error thrown if accessing from different site collection to 
        }
    }

但是,如果我从其他网站集访问提供者托管的应用程序,则无法访问该列表(得到未找到文件)例外。

如何使用CSOM Microsoft.SharePoint.Client库访问另一个网站集中包含的列表?

如何在CSOM /提供商托管的应用程序中“跨网站集合”读取列表?

“本地”,我将使用列表的URL打开SPSite ...但是到目前为止,我在CSOM / SharePointOnline中尝试的所有操作都失败了。

c# sharepoint sharepoint-online csom provider-hosted
1个回答
0
投票

尝试创建您要访问的网站集的上下文。

ClientContext context = new ClientContext(“[Site URL]”);
Web web = context.Web;
context.Load(web);
context.ExecuteQuery();
© www.soinside.com 2019 - 2024. All rights reserved.