You can break the security inheritance of a Web site, list or list item through the BreakRoleInheritance method of the object, so that role assignments on the parent object no longer applies to the child object.
For example, role assignments on a list no longer applies to a list item.
To use the example in this blog, you'll need,
- A SharePoint 2013 development environment (app isolation required for On-Premises scenario).
- Visual Studio 2012 or Visual Studio 2013 with Office Developer tools for Visual Studio 2012.
- Napa (SharePoint Online only).
- You'll also need to set full control add-in permissions at the Web scope. Only the users who have sufficient permissions to change the list permissions (such as site owners) can run this add-in.
- var siteUrl = 'http://gowthamr.SharePoint.com';
- var listTitle = 'Tutorial List';
- var groupName = 'Gowthamr Owners';
- var targetRoleDefinitionName = 'Contribute';
- var groupId;
- var targetRoleDefinitionId;
-
- $(document).ready( function() {
- breakRoleInheritanceOfList();
- });
-
-
- function breakRoleInheritanceOfList() {
- $.ajax({
- url: siteUrl + '/_api/web/lists/getbytitle(\'' + listTitle
- + '\')/breakroleinheritance(true)',
- type: 'POST',
- headers: { 'X-RequestDigest':$('#__REQUESTDIGEST').val() },
- success: successHandler(),
- error: errorHandler
- });
- }
-
- function successHandler() {
- alert('Request succeeded Successfully.');
- }
-
- function errorHandler(xhr, ajaxOptions, thrownError) {
- alert('Request failed: ' + xhr.status + '\n' + thrownError + '\n' + xhr.responseText);
- }
Was my blog helpful?
If so, please let us know at the bottom of this page. If not, let us know what was confusing or missing and I’ll use your feedback to double-check the facts, add info and update this blog.