ClientFormsIdentity.AuthenticationType Özellik

Tanım

Kullanıcının kimliğini doğrulamak için kullanılan kimlik doğrulama türünü alır.

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

Özellik Değeri

Kullanıcının kimliğini doğrulamak için kullanılan kimlik doğrulama türü.

Uygulamalar

Örnekler

Aşağıdaki örnek kod, bir kullanıcının şu anda istemci uygulama hizmetleri için kimliğinin doğrulanıp doğrulanmamış olduğunu belirlemek üzere bir IIdentity başvuru aracılığıyla bu özelliğin nasıl kullanılacağını gösterir. Bu örnekte uygulamanın, kimlik doğrulama tanımlama bilgisinin süresi dolduğunda kullanıcıların yeniden oturum açması gerekmediği varsayılan yapılandırmada olduğu varsayılır. Aksi takdirde, WebException kullanıcı oturum açma süresinin dolduğunu gösterebilir.

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

Açıklamalar

Bu sınıfa doğrudan bağımlılıktan kaçınmak için genellikle bir nesneye başvuru olarak IIdentity erişebilirsinizClientFormsIdentity. Kimliğin özelliğini denetleyerek kullanıcının kimliğinin IIdentity.IsAuthenticated doğrulanıp doğrulanmamış olduğunu belirleyebilirsiniz. Ancak kullanıcının kimliği Windows için doğrulanabilir ancak istemci uygulama hizmetleri için doğrulanmaz. Kullanıcının istemci uygulama hizmetleri için kimliğinin doğrulanıp doğrulanmadığını belirlemek için özellik değerinin IIdentity.AuthenticationType "ClientForms" olduğunu da onaylamanız gerekir. Daha fazla bilgi için bkz. sınıfa ClientFormsIdentity genel bakış.

Şunlara uygulanır

Ayrıca bkz.