SPRoleDefinitionCollection.BreakInheritance method

Creates unique role definitions for the current Web site, optionally copies the role definitions from the parent Web site, and optionally maintains the role assignments.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Sub BreakInheritance ( _
    CopyRoleDefinitions As Boolean, _
    KeepRoleAssignments As Boolean _
)
'Usage
Dim instance As SPRoleDefinitionCollection
Dim CopyRoleDefinitions As Boolean
Dim KeepRoleAssignments As Boolean

instance.BreakInheritance(CopyRoleDefinitions, _
    KeepRoleAssignments)
public void BreakInheritance(
    bool CopyRoleDefinitions,
    bool KeepRoleAssignments
)

Parameters

  • CopyRoleDefinitions
    Type: System.Boolean

    true to copy the role definitions of the parent Web site when breaking inheritance; false to use the default role definitions from the template.

  • KeepRoleAssignments
    Type: System.Boolean

    true to maintain role assignments; otherwise, false.

Exceptions

Exception Condition
ArgumentException()

The CopyRoleDefinitions parameter is false and the KeepRoleAssignments parameter is true.

Remarks

Breaking role definition inheritance also breaks role assignment inheritance, which results in unique role assignments on the Web site. As a result, after this method is called the values of the HasUniqueRoleDefinitions property and the HasUniqueRoleAssignments property are both set to true.

If the Web site already has unique role definitions, this method returns without making any changes.

This method cannot copy role assignments without role definitions. Therefore, if the CopyRoleDefinitions parameter is false and the KeepRoleAssignments parameter is true, an exception is thrown.

See also

Reference

SPRoleDefinitionCollection class

SPRoleDefinitionCollection members

Microsoft.SharePoint namespace

RoleDefinitions