Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SharePoint,模拟后引发异常_Sharepoint - Fatal编程技术网

SharePoint,模拟后引发异常

SharePoint,模拟后引发异常,sharepoint,Sharepoint,我们正在模拟SharePoint用户并尝试访问列表项 using (SPSite site = new SPSite(BAH.SN.Properties.Settings.Default.RootSiteUrl, new SPUserToken(currentUser.ImpersonationToken))) { using (SPWeb web = site.RootWeb) { SPList l

我们正在模拟SharePoint用户并尝试访问列表项

using (SPSite site = new SPSite(BAH.SN.Properties.Settings.Default.RootSiteUrl, new SPUserToken(currentUser.ImpersonationToken)))
        {
            using (SPWeb web = site.RootWeb)
            {
                SPList list = web.GetList(BAH.SN.Properties.Settings.Default.CommunitiesListPath);
                if (list != null)
                {
                    SPQuery query = CAMLHelper.GetSPQueryForCommunityListByOwner(user.UserName);
                    SPListItemCollection items = list.GetItems(query);
                    if (items != null && items.Count > 0)
                    {
                        // Read here
                    }
                }
            }
        }
我们可以获取列表上的句柄,但只要我们尝试访问SPListItemCollection“items”的任何属性,就会得到一个COM异常:532459699

我们正在运行FBA,调用此代码的用户是匿名用户


亲切问候,

您是否尝试过使用
提升特权
而不是令牌

SPSecurity.RunWithElevatedPrivileges(delegate() { 
    //your code inside here, except use the SPSite ctor that only takes the url and get that frome SPContext:
    // new SPSite(SPContext.Current.Site.Url);
}
另外,请提供完整的堆栈跟踪,以给我们最好的方式来帮助您。
如果您不知道如何在
web.config
中启用该功能,请查看有关该问题的众多博客文章中的一篇。

SPSecurity.RunWithElevatedPrivileges
将在系统帐户中运行该代码。这不能解决他/她的问题