AppDomain.SetPrincipalPolicy Method (PrincipalPolicy)


Specifies how principal and identity objects should be attached to a thread if the thread attempts to bind to a principal while executing in this application domain.

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

[<SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)>]
abstract SetPrincipalPolicy : 
        policy:PrincipalPolicy -> unit
[<SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)>]
override SetPrincipalPolicy : 
        policy:PrincipalPolicy -> unit


Type: System.Security.Principal.PrincipalPolicy

One of the PrincipalPolicy values that specifies the type of the principal object to attach to threads.

Exception Condition

The operation is attempted on an unloaded application domain.

Setting this value will only be effective if you set it before using the Thread.CurrentPrincipal property. For example, if you set Thread.CurrentPrincipal to a given principal (for example, a generic principal) and then use the SetPrincipalPolicy method to set the PrincipalPolicy to WindowsPrincipal, the current principal will remain the generic principal.

The following example shows the effect on threads of using the SetPrincipalPolicy method to change the principal policy of the application domain. It also shows the effect of using the SetThreadPrincipal method to change the principal that is available for attaching to threads in the application domain.

No code example is currently available or this language may not be supported.


for ability to manipulate the principal object. Associated enumeration: SecurityPermissionFlag.ControlPrincipal. Security action: Demand.

.NET Framework
Available since 1.1
Return to top