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.
false if the stack contains no partially trusted application domains, no partially trusted assemblies, and no currently active CodeAccessPermission.PermitOnly or CodeAccessPermission.Deny modifiers; true if the common language runtime cannot guarantee that the stack contains none of these.
You can use the SecurityManager.CurrentThreadRequiresSecurityContextCapture method before you cache sensitive data that is obtained after successful security demands.
If the CodeAccessPermission.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 CodeAccessPermission.Assert may become available to code that is no longer be running with that CodeAccessPermission.Assert in place.
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.
SecurityManager.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.