IPrincipal Interface

Namespace: System.Security.Principal Assembly: System.dll

Overview

Represents the security principal for whom the code is running. A principal is an entity that can perform an action. The principal object represents the user or process on whose behalf an operation is being performed.

The IPrincipal interface is the base interface for all principal objects in the .NET Framework. A principal object is typically associated with an identity object that represents the user's identity.

Syntax

public interface IPrincipal

Remarks

The IPrincipal interface is fundamental to the .NET Framework's security model. It provides a way to represent authenticated users and to check their roles.

The most common implementation of IPrincipal is the WindowsPrincipal class, which represents a user logged into a Windows operating system. Other implementations can be created for custom authentication scenarios.

Key methods and properties of IPrincipal allow you to:

  • Determine the identity of the principal.
  • Check if the principal is in a specific role.

Members

Identity Property

IIdentity Identity { get; }

Gets the identity of the current principal.

IsInRole Method

bool IsInRole(string role)

Determines whether the current principal is a member of the specified role.

Implements

This interface explicitly implements the IIdentity interface for the Identity property.

public interface IIdentity