SharePoint,模拟后引发异常
我们正在模拟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
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
将在系统帐户中运行该代码。这不能解决他/她的问题