ClientFormsIdentity.AuthenticationType Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
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. V tomto příkladu se předpokládá, že aplikace je ve výchozí konfiguraci, kde se uživatelé nemusí při vypršení platnosti ověřovacího souboru cookie znovu přihlásit. Jinak může značí, WebException ž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
K objektu ClientFormsIdentity obvykle přistupujete jako IIdentity odkaz, abyste se vyhnuli přímé závislosti na této třídě. To, jestli je uživatel ověřený, můžete určit tak, že zkontrolujete IIdentity.IsAuthenticated vlastnost identity. Uživatel se ale může ověřit pro Windows, ale ne pro služby klientských aplikací. Chcete-li zjistit, zda je uživatel ověřen pro služby klientských aplikací, měli byste také potvrdit, že IIdentity.AuthenticationType hodnota vlastnosti je ClientForms. Další informace najdete v přehledu ClientFormsIdentity třídy.