共用方式為


WindowsAuthentication 類別

提供驗證服務實作,該實作會使用從網域服務產生的 DomainContext 來執行 Windows 驗證,該網域服務則會實作 IAuthentication 介面。

命名空間: System.ServiceModel.DomainServices.Client.ApplicationServices
組件: System.ServiceModel.DomainServices.Client.Web (於 system.servicemodel.domainservices.client.web.dll)

使用方式

'用途
Dim instance As WindowsAuthentication

語法

'宣告
Public Class WindowsAuthentication
    Inherits WebAuthenticationService
public class WindowsAuthentication : WebAuthenticationService
public ref class WindowsAuthentication : public WebAuthenticationService
public class WindowsAuthentication extends WebAuthenticationService
public class WindowsAuthentication extends WebAuthenticationService

備註

若要設定應用程式使用 Windows 驗證,您必須在伺服器和用戶端專案中設定值。當您在用戶端專案中設定值時,您會使用 WindowsAuthentication 類別。

在伺服器專案的 Web.config 檔案中,將 authentication mode 設定為 “Windows”,如下列範例所示。

<system.web>
  <authentication mode="Windows"></authentication>
</system.web>

在用戶端應用程式之 Application 物件的建構函式中,將 WebContext 物件的 Authentication 屬性設定為 WindowsAuthentication,如下列範例所示。此建構函式通常會在名為 App.xaml.cs 或 App.xaml.vb 的檔案中。

Public Sub New()
    InitializeComponent()

    Dim webContext As New WebContext()
    'webContext.Authentication = New FormsAuthentication()
    webContext.Authentication = New WindowsAuthentication()
    Me.ApplicationLifetimeObjects.Add(webContext)
End Sub
public App()
{
    InitializeComponent();

    WebContext webContext = new WebContext();
    //webContext.Authentication = new FormsAuthentication();
    webContext.Authentication = new WindowsAuthentication();
    this.ApplicationLifetimeObjects.Add(webContext);
}

繼承階層

System.Object
   System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService
     System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService
      System.ServiceModel.DomainServices.Client.ApplicationServices.WindowsAuthentication

執行緒安全性

任何這個類型的公用靜態 (在 Visual Basic 中為 共用) 成員都具備執行緒安全。 不保證任何執行個體成員安全執行緒。

平台

開發平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 、Windows Server 2008 和 Windows 2000

目標平台

Change History

另請參閱

參考

WindowsAuthentication 成員
System.ServiceModel.DomainServices.Client.ApplicationServices 命名空間