ClientFormsIdentity.AuthenticationType Propiedad

Definición

Obtiene el tipo de autenticación utilizado para autenticar al usuario.

public:
 property System::String ^ AuthenticationType { System::String ^ get(); };
public string AuthenticationType { get; }
member this.AuthenticationType : string
Public ReadOnly Property AuthenticationType As String

Valor de propiedad

Tipo de autenticación utilizado para autenticar al usuario.

Implementaciones

Ejemplos

En el código de ejemplo siguiente se muestra cómo usar esta propiedad a través de una IIdentity referencia para determinar si un usuario está autenticado actualmente para los servicios de aplicaciones cliente. En este ejemplo se supone que la aplicación está en la configuración predeterminada en la que los usuarios no tienen que volver a iniciar sesión cuando expire la cookie de autenticación. De lo contrario, WebException puede indicar que el inicio de sesión del usuario ha expirado.

private void SaveSettings()
{
    System.Security.Principal.IIdentity identity = 
        System.Threading.Thread.CurrentPrincipal.Identity;

    // Return if the user is not authenticated.
    if (identity == null || !identity.IsAuthenticated) return;

    // Return if the authentication type is not "ClientForms". 
    // This indicates that the user is not authenticated for 
    // client application services.
    if (!identity.AuthenticationType.Equals("ClientForms")) return;

    try
    {
        Properties.Settings.Default.Save();
    }
    catch (System.Net.WebException)
    {
        MessageBox.Show("Unable to access the Web settings service. " +
            "Settings were not saved on the remote service.", 
            "Not logged in", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    }
}
Private Sub SaveSettings()

    Dim identity As System.Security.Principal.IIdentity = _
        System.Threading.Thread.CurrentPrincipal.Identity

    ' Return if the user is not authenticated.
    If identity Is Nothing OrElse Not identity.IsAuthenticated Then Return

    ' Return if the authentication type is not "ClientForms". This indicates
    ' that the user is not authenticated for client application services.
    If Not identity.AuthenticationType.Equals("ClientForms") Then Return

    Try

        My.Settings.Save()

    Catch ex As System.Net.WebException

        MessageBox.Show("Unable to access the Web settings service. " & _
            "Settings were not saved on the remote service.", _
            "Not logged in", MessageBoxButtons.OK, MessageBoxIcon.Warning)

    End Try

End Sub

Comentarios

Normalmente, tendrá acceso a un ClientFormsIdentity objeto como IIdentity referencia para evitar una dependencia directa de esta clase. Puede determinar si un usuario está autenticado comprobando la IIdentity.IsAuthenticated propiedad de la identidad. Sin embargo, el usuario se puede autenticar para Windows, pero no para los servicios de aplicaciones cliente. Para determinar si el usuario está autenticado para los servicios de aplicaciones cliente, también debe confirmar que el valor de la IIdentity.AuthenticationType propiedad es "ClientForms". Para obtener más información, consulte la información general de la ClientFormsIdentity clase.

Se aplica a

Consulte también