Share via


Classe WindowsAuthentication

Fornisce un'implementazione del servizio di autenticazione che esegue l'autenticazione di Windows utilizzando un oggetto DomainContext generato da un servizio del dominio che implementa l'interfaccia IAuthentication.

Spazio dei nomi: System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly: System.ServiceModel.DomainServices.Client.Web (in system.servicemodel.domainservices.client.web.dll)

Utilizzo

'Utilizzo
Dim instance As WindowsAuthentication

Sintassi

'Dichiarazione
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

Osservazioni

Per configurare l'applicazione in modo da utilizzare l'autenticazione di Windows, è necessario impostare i valori sia nel progetto server che in quello client. È possibile utilizzare la classe WindowsAuthentication per impostare il valore nel progetto client.

Nel file Web.config del progetto server impostare la modalità di autenticazione su “Windows”, come illustrato nell'esempio seguente.

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

Nel costruttore dell'oggetto Application per l'applicazione client impostare la proprietà Authentication dell'oggetto WebContext su WindowsAuthentication, come illustrato nell'esempio seguente. Il costruttore si trova in genere in un file denominato App.xaml.cs o 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);
}

Gerarchia di ereditarietà

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

Sicurezza dei thread

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. Non è invece garantita la sicurezza dei membri dell'istanza.

Piattaforme

Piattaforme di sviluppo

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 , Windows Server 2008 e Windows 2000

Piattaforme di destinazione

Change History

Vedere anche

Riferimento

Membri WindowsAuthentication
Spazio dei nomi System.ServiceModel.DomainServices.Client.ApplicationServices