Showing posts with label access denied. Show all posts
Showing posts with label access denied. Show all posts

Wednesday, August 18, 2010

SharePoint: Check Item Level Permission

Use
listItem.DoesUserHavePermissions(perms)
This method will return true or false.

Avoid
list.CheckPermissions(perms)
This method throws an Unauthorised Access Exception if current user does not have permissions, which will override the try-catch and causes an auto-redirection to an Access Denied Page.



Monday, March 29, 2010

Getting SharePoint subwebs

You may encounter access denied problems when you try to run the code web.Webs using a non-admin account. This problem may occur even when the user account has access to all the subsite of the particular web. The entire page in which the webpart is in becomes "Access Denied" although only the webpart is affected.

SPSecurity.CatchAccessDeniedException = false; will allow the user to access the page, but the webpart would display an "Unauthorised Access Exception".

A more accurate function would be web.GetSubwebsForCurrentUser()