AppDomain.SetThreadPrincipal Method (IPrincipal)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Sets the default principal object to be attached to threads if they attempt 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 SetThreadPrincipal : 
        principal:IPrincipal -> unit
[<SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlPrincipal)>]
override SetThreadPrincipal : 
        principal:IPrincipal -> unit


Type: System.Security.Principal.IPrincipal

The principal object to attach to threads.

Exception Condition

principal is null.


The thread principal has already been set.


The operation is attempted on an unloaded application domain.

The following example shows the effect of using the SetThreadPrincipal method to change the principal that is available for attaching to threads that are executing in the application domain. It also shows the effect on threads of using the SetPrincipalPolicy method to change the principal policy of 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