HostProtectionAttribute.SecurityInfrastructure 속성

정의

보안 인프라가 노출되는지 여부를 나타내는 값을 가져오거나 설정합니다.Gets or sets a value indicating whether the security infrastructure is exposed.

public:
 property bool SecurityInfrastructure { bool get(); void set(bool value); };
public bool SecurityInfrastructure { get; set; }
[System.Runtime.InteropServices.ComVisible(true)]
public bool SecurityInfrastructure { get; set; }
member this.SecurityInfrastructure : bool with get, set
[<System.Runtime.InteropServices.ComVisible(true)>]
member this.SecurityInfrastructure : bool with get, set
Public Property SecurityInfrastructure As Boolean

속성 값

Boolean

보안 인프라가 노출되면 true이고, 그렇지 않으면 false입니다.true if the security infrastructure is exposed; otherwise, false. 기본값은 false입니다.The default is false.

특성

예제

다음 코드 예제에서는 속성을 사용 하 여 특성을 사용 하는 방법을 보여 줍니다 HostProtectionAttribute SecurityInfrastructure .The following code example illustrates the use of the HostProtectionAttribute attribute with the SecurityInfrastructure property. 이 예제는에 대해 제공 된 큰 예제의 일부는 HostProtectionAttribute 클래스입니다.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.
// ApplyIdentity sets the current identity.

[HostProtection(SharedState=true,SelfAffectingThreading=true,
SecurityInfrastructure=true)]
static int ApplyIdentity()
{
   array<String^>^roles = {"User"};
   try
   {
      AppDomain^ mAD = AppDomain::CurrentDomain;
      GenericPrincipal^ mGenPr = gcnew GenericPrincipal( WindowsIdentity::GetCurrent(),roles );
      mAD->SetPrincipalPolicy( PrincipalPolicy::WindowsPrincipal );
      mAD->SetThreadPrincipal( mGenPr );
      return Success;
   }
   catch ( Exception^ e ) 
   {
      Exit( e->ToString(), 5 );
   }

   return 0;
}
// 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)]
// ApplyIdentity sets the current identity.
private static int ApplyIdentity()
{
    string[] roles = {"User"};
    try
    {
        AppDomain mAD = AppDomain.CurrentDomain;
        GenericPrincipal mGenPr = 
            new GenericPrincipal(WindowsIdentity.GetCurrent(), roles);
        mAD.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
        mAD.SetThreadPrincipal(mGenPr);
        return Success;
    }
    catch (Exception e)
    {
        Exit(e.ToString(), 5);
    }
    return 0;
}
' 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

설명

WindowsIdentity사용자를 가장 하는 데 개체를 사용 하는 것은 보안 인프라를 노출 하는 예입니다.The use of a WindowsIdentity object to impersonate a user is an example of exposing the security infrastructure.

적용 대상

추가 정보