This documentation is archived and is not being maintained.

PrincipalPermission.Demand Method

Determines at run time whether the current principal matches the principal specified by the current permission.

Namespace: System.Security.Permissions
Assembly: mscorlib (in mscorlib.dll)

public void Demand ()
public final void Demand ()
public final function Demand ()

Exception typeCondition

SecurityException

The current principal does not pass the security check for the principal specified by the current permission.

-or-

The current IPrincipal is a null reference (Nothing in Visual Basic).

If no SecurityException is raised, Demand succeeds.

This method acts against the principal attached to the calling thread.

NoteImportant:

Prior to calling the Demand method, it is necessary to set the current application domain's principal policy to the enumeration value WindowsPrincipal. By default the principal policy is set to UnauthenticatedPrincipal. If you do not set the principal policy to WindowsPrincipal, a demand for principal permission will fail. The following code should be executed before the demand for principal permission occurs:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).

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

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

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: