0

I need to give permission to some limited users to one of the site page. How can i achieve this programmatically?

For example: If I have created a page programmatically in a library called "SitePages", then that page should be visible to only few people to whom I give permission.

  • Please give an example of how you would like this to work. – James Flattery Sep 14 '15 at 15:20
0

This will work I think

                   item.BreakRoleInheritance(false);
                   while (item.RoleAssignments.Count > 0)  
                    { 
                        item.RoleAssignments.Remove(0); 
                    }


                   // Give permissions to a specific group
                   SPUser group = web.EnsureUser(strListItemSecurity_Group);
                   SPRoleAssignment roleassignment_group = new SPRoleAssignment(group);
                   roleassignment_group.RoleDefinitionBindings.Add(web.RoleDefinitions[strTHTListItemSecurity_Group_Role]);
                   item.RoleAssignments.Add(roleassignment_group);
| improve this answer | |
1

There is an code example in this article:

https://msdn.microsoft.com/library/Microsoft.SharePoint.SPRoleAssignment

You would modify it slightly, to add your new role assignment to the page itself, of course.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.