IPrincipal Interface
Assembly: mscorlib.dll
Summary
Represents the security principal for which the calling code is executing. A principal is an entity that can be authenticated, such as a user or a process.
Interface Members
The IPrincipal interface defines the following members:
Identity Property
Gets the IIdentity object associated with the current principal.
Syntax:
IIdentity Identity { get; }
Property Value:
An IIdentity object that represents the authenticated identity of the caller.
IsInRole Method
Determines whether the current principal is a member of the specified role.
Syntax:
bool IsInRole(string role);
Parameters:
role: A string representing the name of the role to check.
Return Value:true if the principal is a member of the specified role; otherwise, false.
Remarks:
This method is used to enforce role-based security. For example, you can check if a user belongs to an "Administrator" role before allowing them to perform an action.
Requirements
Namespace: System.Security.Permissions
Assembly: mscorlib.dll