Freigeben über


SPSecurityTrimmedControl Class

Conditionally renders the contents of the control to the current user only if the current user has permissions defined in the PermissionString.

Inheritance Hierarchy

System.Object
  System.Web.UI.Control
    System.Web.UI.WebControls.WebControl
      Microsoft.SharePoint.WebControls.SPSecurityTrimmedControl
        Microsoft.SharePoint.WebControls.SPLinkButton

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

Syntax

<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class SPSecurityTrimmedControl _
    Inherits WebControl _
    Implements IDesignerEventAccessor

Dim instance As SPSecurityTrimmedControl
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class SPSecurityTrimmedControl : WebControl, 
    IDesignerEventAccessor

Remarks

Allows the conditional display of content depending on the user’s permission. The content can be any HTML code or other controls. One use of the SPSecurityTrimmedControl is to hide the Site Actions menu and the Publishing Console from anonymous users:

Examples

<SharePoint:SPSecurityTrimmedControl ID=”SPSecurityTrimmedControl1″
  PermissionsString=”BrowseDirectories” runat=”server”>
    <PublishingSiteAction:SiteActionMenu runat=”server” />
    <wssuc:Welcome id=”explitLogout” runat=”server” />
    <PublishingWebControls:AuthoringContainer ID=”authoringcontrols”
    runat=”server”>
        <PublishingConsole:Console runat=”server” />
    </PublishingWebControls:AuthoringContainer>
</SharePoint:SPSecurityTrimmedControl>

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

SPSecurityTrimmedControl Members

Microsoft.SharePoint.WebControls Namespace