Condividi tramite


SPWeb.BreakRoleInheritance Method (Boolean, Boolean)

Creates unique role assignments for the website, optionally copies role assignments from the parent website, and optionally clears unique role assignments from descendants.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "a", ErrorType := GetType(SPException),  _
    Condition := "This site is a root site.", ErrorCode := )> _
<ClientCallableExceptionConstraintAttribute(FixedId := "b", ErrorType := GetType(InvalidOperationException),  _
    Condition := "There are uncommitted changes on the site", ErrorCode := )> _
<ClientCallableAttribute> _
Public Overrides Sub BreakRoleInheritance ( _
    copyRoleAssignments As Boolean, _
    clearSubscopes As Boolean _
)
'Usage
Dim instance As SPWeb
Dim copyRoleAssignments As Boolean
Dim clearSubscopes As Boolean

instance.BreakRoleInheritance(copyRoleAssignments, _
    clearSubscopes)
[ClientCallableExceptionConstraintAttribute(FixedId = "a", ErrorType = typeof(SPException), 
    Condition = "This site is a root site.", ErrorCode = )]
[ClientCallableExceptionConstraintAttribute(FixedId = "b", ErrorType = typeof(InvalidOperationException), 
    Condition = "There are uncommitted changes on the site", ErrorCode = )]
[ClientCallableAttribute]
public override void BreakRoleInheritance(
    bool copyRoleAssignments,
    bool clearSubscopes
)

Parameters

  • copyRoleAssignments
    Type: System.Boolean

    true to specify role assignments are copied from the parent website to this website; false to specify only the current user is assigned to security roles.

  • clearSubscopes
    Type: System.Boolean

    true to specify unique role assignments are cleared from child objects and then inherit role assignments from this website; false to specify unique role assignments defined on child objects are left in place.

Exceptions

Exception Condition
SPException

You cannot change permissions on the root website of a site collection.

Remarks

This method breaks the inheritance of role assignments from the parent website, and creates unique role assignments for the current website.

See Also

Reference

SPWeb Class

SPWeb Members

BreakRoleInheritance Overload

Microsoft.SharePoint Namespace

ParentWeb