我们有一个Webpart显示与用户的链接。这些可以是listItems,列表或网站。在页面加载中,我们检查用户是否具有访问每个链接所需的权限。如果他们不这样做,链接将不会为他们呈现。我们提供的解决方案可以正常工作,并且链接可以按预期呈现。
我们使用DoesUserHavePermission方法检查权限,该方法可用于列表项,列表和网站。这样可以正常工作,并根据用户权限返回正确的结果。
问题是调用此方法时,即使它可以正常工作,它也会在ULS日志中引发异常。例外的示例如下:
da8aa23f-abe9-4edf-853e-a8d602751524 Stack trace:
at Microsoft.SharePoint.SPWeb.InitWebPublic()
at Microsoft.SharePoint.Utilities.SPUtility.GetPermissionsCore(SPUserToken token, SPSecurableObject securableObject, Boolean getAssignments, Boolean useCache)
at Microsoft.SharePoint.Utilities.SPUtility.DoesUserHavePermissions(SPUser user, SPBasePermissions permissionMask, SPSecurableObject securableObject)
at Intranet.WebParts.Tile.Security.CheckListItemPermissions(SPListItem listItem)
at Intranet.WebParts.Tile.Tile.RunWithoutCatchingAccessDenied[T](Func`1 func)
at Intranet.WebParts.Tile.Tile.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at Microsoft.SharePoint.Publishing.TemplateRedirectionPage.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
at System.Web.HttpApplication.PipelineStepManager.ResumeSteps(Exception error)
at System.Web.HttpApplication.BeginProcessRequestNotification(HttpContext context, AsyncCallback cb)
at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.UnsafeIISMethods.MgdIndicateCompletion(IntPtr pHandler, RequestNotificationStatus& notificationStatus)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
下面是调用diduserhavepermission的代码段:
web.DoesUserHavePermissions(SPContext.Current.Web.CurrentUser.LoginName, SPBasePermissions.ViewPages);
获取网络和调用方法之间的上下文是相同的。我试图提升权限,但没有运气。
我先问一下这里,然后再向Microsoft提出。预先感谢。