Click to Rate and Give Feedback
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
SecurityRoleAttribute Class

Updated: November 2007

Configures a role for an application or component. This class cannot be inherited.

Namespace:  System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

Visual Basic (Declaration)
<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Method Or AttributeTargets.Interface, Inherited := True,  _
    AllowMultiple := True)> _
<ComVisibleAttribute(False)> _
Public NotInheritable Class SecurityRoleAttribute _
    Inherits Attribute
Visual Basic (Usage)
Dim instance As SecurityRoleAttribute
C#
[AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface, Inherited = true, 
    AllowMultiple = true)]
[ComVisibleAttribute(false)]
public sealed class SecurityRoleAttribute : Attribute
Visual C++
[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Method|AttributeTargets::Interface, Inherited = true, 
    AllowMultiple = true)]
[ComVisibleAttribute(false)]
public ref class SecurityRoleAttribute sealed : public Attribute
J#
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface, Inherited = true, AllowMultiple = true) */
/** @attribute ComVisibleAttribute(false) */
public final class SecurityRoleAttribute extends Attribute
JScript
public final class SecurityRoleAttribute extends Attribute

You can use the SecurityRoleAttribute to add roles to an application, and to associate them with components. When SecurityRoleAttribute is applied to an assembly as a whole, it ensures that the role exists in the application configuration (COM+ catalog). You can add members of the role using the COM+ Explorer.

When applied to a component, the SecurityRoleAttribute ensures that the role exists in the application configuration, and associates the target component with the role.

By default, created roles have no members. If the SetEveryoneAccess property is set to true, the Everyone user group is automatically added to the role. This is best for all-access type roles that are given minimal control over the system.

Security roles can be specified at the component level, per interface and per method. As with other method attributes, security configuration is not currently shared between interface definition and method implementation.

The following code example demonstrates the use of this attribute to associate a role with an assembly that contains ServicedComponent classes.

Visual Basic
' Create a security role for the component.
<Assembly: SecurityRole("Manager")> 

C#
// Create a security role for the component.
[assembly: SecurityRole("Manager")]

Visual C++
// Create a security role for the component.
[assembly:SecurityRole("Manager")];

J#
// Create a security role for the component.
/** @assembly SecurityRole("Manager")
 */

System..::.Object
  System..::.Attribute
    System.EnterpriseServices..::.SecurityRoleAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker