ClientFormsIdentity.AuthenticationType Vlastnost

Definice

Získá typ ověřování, který se používá k ověření uživatele.

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

Hodnota vlastnosti

Typ ověřování, který se používá k ověření uživatele.

Implementuje

Příklady

Následující příklad kódu ukazuje, jak použít tuto vlastnost prostřednictvím IIdentity odkazu k určení, zda je uživatel aktuálně ověřen pro klientské aplikační služby. Tento příklad předpokládá, že aplikace je ve výchozí konfiguraci, kde se uživatelé nemusí přihlašovat znovu, když vyprší platnost ověřovacího souboru cookie. Jinak může hodnota WebException znamenat, že vypršela platnost přihlášení uživatele.

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

Poznámky

Obvykle budete přistupovat k objektu ClientFormsIdentity jako odkaz, IIdentity aby se zabránilo přímé závislosti na této třídě. Ověření uživatele můžete zjistit tak, že zkontrolujete IIdentity.IsAuthenticated vlastnost identity. Uživatel však může být ověřený pro Windows, ale ne pro klientské aplikační služby. Chcete-li zjistit, zda je uživatel ověřen pro klientské aplikační služby, měli byste také ověřit, že IIdentity.AuthenticationType hodnota vlastnosti je "ClientForms". Další informace najdete v přehledu ClientFormsIdentity třídy.

Platí pro

Viz také