HostProtectionAttribute.SecurityInfrastructure Property

Gets or sets a value indicating whether the security infrastructure is exposed.

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

'Declaration
<ComVisibleAttribute(True)> _
Public Property SecurityInfrastructure As Boolean

Property Value

Type: System.Boolean
true if the security infrastructure is exposed; otherwise, false. The default is false.

The use of a WindowsIdentity object to impersonate a user is an example of exposing the security infrastructure.

The following code example illustrates the use of the HostProtectionAttribute attribute with the SecurityInfrastructure property. This example is part of a larger example provided for the HostProtectionAttribute class.

' Use the enumeration flags to indicate that this method exposes shared   
' state, self-affecting threading, and the security infrastructure.
<HostProtectionAttribute(SharedState := True, _
    SelfAffectingThreading := True, _
    SecurityInfrastructure := True)> _
Private Shared Function ApplyIdentity() As Integer 

    ' ApplyIdentity sets the current identity. 
    Dim roles(1) As String 
    Try 
        Dim mAD As AppDomain = AppDomain.CurrentDomain
        Dim mGenPr As _
            New GenericPrincipal(WindowsIdentity.GetCurrent(), roles)
        mAD.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
        mAD.SetThreadPrincipal(mGenPr)
        Return Success
    Catch e As Exception
        [Exit](e.ToString(), 5)
    End Try 
    Return 0
End Function 'ApplyIdentity

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft