Share via


HostProtectionAttribute.SecurityInfrastructure Propiedad

Definición

Obtiene o establece un valor que indica si la infraestructura de seguridad está expuesta.

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

Valor de propiedad

true si la infraestructura de seguridad está expuesta; de lo contrario, false. De manera predeterminada, es false.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra el uso del HostProtectionAttribute atributo con la SecurityInfrastructure propiedad . Este ejemplo forma parte de un ejemplo más grande proporcionado para la HostProtectionAttribute clase .

// 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

Comentarios

El uso de un WindowsIdentity objeto para suplantar a un usuario es un ejemplo de la exposición de la infraestructura de seguridad.

Se aplica a

Consulte también