Compartilhar via


WindowsAuthentication Class

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Provides an authentication service implementation that performs Windows authentication using a DomainContext generated from a domain service implementing the IAuthentication<T> interface.

Inheritance Hierarchy

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

Namespace:  System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly:  System.ServiceModel.DomainServices.Client.Web (in System.ServiceModel.DomainServices.Client.Web.dll)

Syntax

'Declaration
Public Class WindowsAuthentication _
    Inherits WebAuthenticationService
'Usage
Dim instance As WindowsAuthentication
public class WindowsAuthentication : WebAuthenticationService
public ref class WindowsAuthentication : public WebAuthenticationService
type WindowsAuthentication =  
    class
        inherit WebAuthenticationService
    end
public class WindowsAuthentication extends WebAuthenticationService

The WindowsAuthentication type exposes the following members.

Constructors

  Name Description
Public method WindowsAuthentication Initializes a new instance of the WindowsAuthentication class.

Top

Properties

  Name Description
Public property DomainContext Gets or sets the domain context this service delegates authenticating, loading, and saving to. (Inherited from WebAuthenticationService.)
Public property DomainContextType Gets or sets the type of the domain context. (Inherited from WebAuthenticationService.)
Public property IsBusy Gets a value indicating whether an asynchronous operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoadingUser Gets a value indicating whether an asynchronous LoadUser operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoggingIn Gets a value indicating whether an asynchronous Login operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoggingOut Gets a value indicating whether an asynchronous Logout operation is in progress. (Inherited from AuthenticationService.)
Public property IsSavingUser Gets a value indicating whether an asynchronous SaveUser operation is in progress. (Inherited from AuthenticationService.)
Protected property SupportsCancellation Gets a value that indicates whether this service supports cancellation. (Inherited from WebAuthenticationService.)
Public property User Gets a principal representing the authenticated user. (Inherited from AuthenticationService.)

Top

Methods

  Name Description
Protected method BeginLoadUser Begins an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method BeginLogin Login is not a supported operation for Windows authentication. (Overrides WebAuthenticationService.BeginLogin(LoginParameters, AsyncCallback, Object).)
Protected method BeginLogout Logout is not a supported operation for Windows authentication. (Overrides WebAuthenticationService.BeginLogout(AsyncCallback, Object).)
Protected method BeginSaveUser Begins an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected method CancelLoadUser Cancels an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method CancelLogin Cancels an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected method CancelLogout Cancels an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected method CancelSaveUser Cancels an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected method CreateDefaultUser Creates a default user. (Inherited from WebAuthenticationService.)
Protected method EndLoadUser Ends an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method EndLogin Ends an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected method EndLogout Ends an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected method EndSaveUser Ends an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method Initialize Initializes this authentication service. (Inherited from WebAuthenticationService.)
Public method LoadUser() Asynchronously loads the authenticated user from the server. (Inherited from AuthenticationService.)
Public method LoadUser(Action<LoadUserOperation>, Object) Asynchronously loads the authenticated user from the server with specified callback method and user state. (Inherited from AuthenticationService.)
Public method Login(LoginParameters) Asynchronously authenticates and logs in to the server with the specified parameters. (Inherited from AuthenticationService.)
Public method Login(String, String) Asynchronously authenticates and logs in to the server with the specified user name and password. (Inherited from AuthenticationService.)
Public method Login(LoginParameters, Action<LoginOperation>, Object) Asynchronously authenticates and logs in to the server with the specified parameters, callback method, and user state. (Inherited from AuthenticationService.)
Public method Logout(Boolean) Asynchronously logs out an authenticated user from the server with the specified value indicating whether an exception is thrown for errors. (Inherited from AuthenticationService.)
Public method Logout(Action<LogoutOperation>, Object) Asynchronously logs out an authenticated user from the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Protected method MemberwiseClone (Inherited from Object.)
Protected method OnPropertyChanged Raises a PropertyChanged event. (Inherited from AuthenticationService.)
Protected method RaisePropertyChanged Raises a PropertyChanged event for the specified property. (Inherited from AuthenticationService.)
Public method SaveUser(Boolean) Asynchronously saves the authenticated user to the server with the specified value indicating whether an exception is thrown for errors. (Inherited from AuthenticationService.)
Public method SaveUser(Action<SaveUserOperation>, Object) Asynchronously saves the authenticated user to the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Public method ToString (Inherited from Object.)

Top

Events

  Name Description
Public event LoggedIn Occurs when a new user is successfully logged in. (Inherited from AuthenticationService.)
Public event LoggedOut Occurs when a user is successfully logged out. (Inherited from AuthenticationService.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate event INotifyPropertyChanged.PropertyChanged Occurs every time a property value changes. (Inherited from AuthenticationService.)

Top

Remarks

To configure your application to use Windows authentication, you must set values in both the server and client project. You use the WindowsAuthentication class when setting the value in the client project.

In the Web.config file of the server project, set the authentication mode to “Windows”, as shown in the following example.

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

In the constructor of the Application object for the client application, set the Authentication property of the WebContext object to WindowsAuthentication, as shown in the following example. The constructor is typically in a file named App.xaml.cs or 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);
}

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.ServiceModel.DomainServices.Client.ApplicationServices Namespace