Friday, March 25, 2011

SharePoint Check Current User Permissions (SPBasePermissions)

I came accross a requirement where a custom web part or page displays the Generic List fields, however hide some of the fields if the current logged-in user doesn't have edit or delete list items permission.
using Microsoft.SharePoint;
if (!SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.EditListItems))
//hide the fields/controls which are not supposed to be shown here
To see the OTB available list of permissions(SPBasePermissions) have a look at the post here.

No comments:

Post a Comment