RolePrincipal Class (System.Web.Security)

Switch View :
ScriptFree
.NET Framework Class Library
RolePrincipal Class

Represents security information for the current HTTP request, including role membership. This class cannot be inherited.

Inheritance Hierarchy

System.Object
  System.Web.Security.RolePrincipal

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)
Syntax

Visual Basic
<SerializableAttribute> _
Public Class RolePrincipal _
	Implements IPrincipal, ISerializable
C#
[SerializableAttribute]
public class RolePrincipal : IPrincipal, 
	ISerializable
Visual C++
[SerializableAttribute]
public ref class RolePrincipal : IPrincipal, 
	ISerializable
F#
[<SerializableAttribute>]
type RolePrincipal =  
    class
        interface IPrincipal
        interface ISerializable
    end

The RolePrincipal type exposes the following members.

Constructors

  Name Description
Public method RolePrincipal(IIdentity) Instantiates a RolePrincipal object for the specified identity.
Public method RolePrincipal(IIdentity, String) Instantiates a RolePrincipal object for the specified identity with role information from the specified encryptedTicket.
Protected method RolePrincipal(SerializationInfo, StreamingContext) Initializes a new instance of the RolePrincipal class using information that is contained in the specified SerializationInfo object and using the specified streaming context.
Public method RolePrincipal(String, IIdentity) Instantiates a RolePrincipal object for the specified identity using the specified providerName.
Public method RolePrincipal(String, IIdentity, String) Instantiates a RolePrincipal object for the specified identity using the specified providerName and role information from the specified encryptedTicket.
Top
Properties

  Name Description
Public property CachedListChanged Gets a value indicating whether the list of role names cached with the RolePrincipal object has been modified.
Public property CookiePath Gets the path for the cached role names cookie.
Public property Expired Gets a value indicating whether the roles cookie has expired.
Public property ExpireDate Gets the date and time when the roles cookie will expire.
Public property Identity Gets the security identity for the current HTTP request.
Public property IsRoleListCached Gets a value indicating whether the list of roles for the user has been cached in a cookie.
Public property IssueDate Gets the date and time that the roles cookie was issued.
Public property ProviderName Gets the name of the role provider that stores and retrieves role information for the user.
Public property Version Gets the version number of the roles cookie.
Top
Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Protected method GetObjectData Populates a SerializationInfo object with the data that is required in order to serialize the target object using the specified streaming context.
Public method GetRoles Gets a list of roles that the RolePrincipal is a member of.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsInRole Gets a value indicating whether the user represented by the RolePrincipal is in the specified role.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method SetDirty Marks the cached role list as having been changed.
Public method ToEncryptedTicket Returns the role information cached with the RolePrincipal object encrypted based on the CookieProtectionValue.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Explicit Interface Implementations

  Name Description
Explicit interface implemetation Private method ISerializable.GetObjectData For a description of this member, see GetObjectData.
Top
Remarks

The RolePrincipal object implements the IPrincipal interface and represents the current security context for the HTTP request.

When role management is enabled (see Roles), the RoleManagerModule assigns a RolePrincipal object to the User property of the Current HttpContext.

The RolePrincipal class exposes the security identity for the current HTTP request and additionally performs checks for role membership. If CacheRolesInCookie is true, then the RolePrincipal object manages the cached list of roles and looks up role membership for the current user in the cached list first, then the role Provider. If CacheRolesInCookie is false, the RolePrincipal object always looks up role membership using the role provider.

The RolePrincipal object encrypts and decrypts role information cached in the cookie identified by the CookieName based on the CookieProtectionValue.

Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
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

Other Resources

Community Content

Brent Schmaltz - MSFT
Can this class be inherited?
Why does this documentation say that the class cannot be inherited?  The class is public and not sealed.