This topic has not yet been rated - Rate this topic

SecurityManager.CurrentThreadRequiresSecurityContextCapture Method

Determines whether the current thread requires a security context capture if its security state has to be re-created at a later point in time.

Namespace:  System.Security
Assembly:  mscorlib (in mscorlib.dll)
public static bool CurrentThreadRequiresSecurityContextCapture()

Return Value

Type: System.Boolean
false if the stack contains no partially trusted application domains, no partially trusted assemblies, and no currently active PermitOnly or Deny modifiers; true if the common language runtime cannot guarantee that the stack contains none of these.

You can use the CurrentThreadRequiresSecurityContextCapture method before you cache sensitive data that is obtained after successful security demands.

If the Assert method has been called higher on the stack, the data should not be cached without capturing the corresponding security context. Otherwise, sensitive data that is obtained under an Assert may become available to code that is no longer be running with that Assert in place.

Important noteImportant

The return value is reliable only when it is false, which means that the thread is guaranteed not to require a security context capture. The method may return true when a security context capture is not necessary, to avoid security vulnerabilities.

CurrentThreadRequiresSecurityContextCapture is security-critical because its main use is to avoid unnecessary security context captures, which indicates that the code using it is security-sensitive and must be audited.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4
  • SecurityCriticalAttribute 

    requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.