Monday, 4 January 2010

Disabling Anonymous access to a custom list programmatically

I stuck with this while disabling the anonymous access programmatically on a custom list.
When anonymous access is enabled on 'Entire Site' the SharePoint opens the anonymous access to all the lists which inherit the permissions from the parent. Even if you try to create the new list  programmatically or via interface, it can be seen by the anonymous users and if the list stores the sensitive data then it becomes the big worry for you.

Here's the way how you can disable anonymous access programmatically:

SPList list = // fetch the desired list;

list.BreakRoleInheritance(false);
// this disables the interface options for anonymous access under permissions settings for the list
list.AnonymousPermMask64 = SPBasePermissions.EmptyMask;


To disable the access via UI follow these steps

  1. List(desired list) > List Settings > Permissions for this list > Actions > Edit Permissions
  2. Un-check - In the Permissions  > Settings > Anonymous Access > View Items

Hope this will help !

Majid

No comments:

Iconise ‘Add Picture’ control in PowerApps

Default look you get for ‘Add Picture’ control is not very appealing for end user and there is no OTB way of specifying icon for this con...