public class AuthenticationManager
Object
AuthenticationManager
System
Networking
Manages the authentication modules called during the client authentication process.
The AuthenticationManager class manages authentication modules that are responsible for client authentication. [Note: The AuthenticationManager is called by WebRequest instances to provide information that is sent to servers to authenticate the client. The authentication process may consist of requests to an authentication server separate from the resource server, as well as any other activities required to properly authenticate a client.]
The AuthenticationManager queries registered authentication modules by calling the System.Net.IAuthenticationModule.Authenticate(System.String,System.Net.WebRequest,System.Net.ICredentials) method for each module. The first authentication module that returns a Authorization instance is used to authenticate the request. An authentication module, which can be any object that implements the IAuthenticationModule interface, is registered using the System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method. Authentication modules are called in the order in which they are registered.
Applications typically do not access this type directly; it provides authentication services for the WebRequest type.
System.Net Namespace
AuthenticationManager Methods
AuthenticationManager.Authenticate Method
AuthenticationManager.PreAuthenticate Method
AuthenticationManager.Register Method
AuthenticationManager.Unregister(System.Net.IAuthenticationModule) Method
AuthenticationManager.Unregister(System.String) Method
AuthenticationManager Properties
public static Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials);
Calls registered authentication modules to find a module that responds to the specified authentication challenge.
- challenge
- A String containing the challenge returned by an Internet host. The content of this string is determined by the authentication protocol(s) used by the server that issued the challenge.
- request
- The WebRequest that received challenge .
- credentials
- The ICredentials associated with request. [Note: The System.Net.WebRequest.Credentials property of request is used to supply this argument.]
A Authorization instance containing the response from the authentication module, ornull
if no authentication module responded to the challenge.Applications do not call this method; it is called by WebRequest instances.
Exception Type Condition ArgumentNullException challenge , request , or credentials is null
.
The System.Net.AuthenticationManager.Authenticate(System.String,System.Net.WebRequest,System.Net.ICredentials) method invokes the System.Net.IAuthenticationModule.Authenticate(System.String,System.Net.WebRequest,System.Net.ICredentials) method of each registered authentication module until one of the modules returns a Authorization instance. Authentication modules are called in the order in which they were registered via the System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method.[Note: The System.Net.Authorization.Message property of the object returned by this method contains the client's response to the server challenge contained in challenge . ]
System.Net.AuthenticationManager Class, System.Net Namespace
public static Authorization PreAuthenticate(WebRequest request, ICredentials credentials);
Attempts to obtain a Authorization instance used to initiate client authentication.
- request
- A WebRequest containing a request for access to a resource.
- credentials
- The ICredentials associated with request .
A Authorization instance if an authentication module can provide authentication information to be sent with request ; otherwise,null
. If credentials isnull
, this method returnsnull
.
Exception Type Condition ArgumentNullException request is null.
The System.Net.AuthenticationManager.PreAuthenticate(System.Net.WebRequest,System.Net.ICredentials) method invokes the System.Net.IAuthenticationModule.PreAuthenticate(System.Net.WebRequest,System.Net.ICredentials) method of each registered authentication module until one of the modules returns a Authorization instance. Authentication modules are called in the order in which they were registered via the System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method.[Note: The Authorization instance contains the information that will be sent by a client to initiate authentication instead of waiting for the server to request it. Authentication modules that support preauthentication allow clients to improve server efficiency by avoiding extra round trips caused by authentication challenges.]
[Note: If an authorization module supports preauthentication of requests, its System.Net.IAuthenticationModule.CanPreAuthenticate property returns
true
. Note that preauthentication requires that an authentication of the client has already occurred. The information obtained from the initial authentication is used to provide the System.Net.Authorization.Message that is sent to the server as an authentication header in request .]
System.Net.AuthenticationManager Class, System.Net Namespace
public static void Register(IAuthenticationModule authenticationModule);
Adds an authentication module to the list of registered authentication modules managed by the authentication manager.
- authenticationModule
- The IAuthenticationModule to register.
Exception Type Condition ArgumentNullException authenticationModule is null
.
The System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method adds an authentication module to the end of the list of modules managed by the authentication manager. Each registered module is required to have a unique System.Net.IAuthenticationModule.AuthenticationType. If a module with the same System.Net.IAuthenticationModule.AuthenticationType is already registered, this method removes the registered module, and adds authenticationModule to the end of the list. [Note: Authentication modules are called in the order in which they were added to the list.]
[Note: To remove a module, call one of the System.Net.AuthenticationManager.Unregister(System.Net.IAuthenticationModule) methods.]
System.Net.AuthenticationManager Class, System.Net Namespace
public static void Unregister(IAuthenticationModule authenticationModule);
Removes the specified authentication module from the list of registered modules.
- authenticationModule
- The IAuthenticationModule module to remove.
Exception Type Condition ArgumentNullException authenticationModule is null
.InvalidOperationException authenticationModule is not a registered authentication module.
[Note: To add an authentication module to the list of registered modules, call the System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method.]
System.Net.AuthenticationManager Class, System.Net Namespace
public static void Unregister(string authenticationScheme);
Removes the authentication module with the specified authentication type from the list of registered modules.
- authenticationScheme
- A String containing the authentication type of the module to remove.
Exception Type Condition ArgumentNullException authenticationScheme is null
.InvalidOperationException There is no registered module with the authenticationScheme authentication type.
The authenticationScheme is required to match the value returned by the System.Net.IAuthenticationModule.AuthenticationType property of a registered authentication module.[Note: To add an authentication module to the list of registered modules, call the System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method.]
System.Net.AuthenticationManager Class, System.Net Namespace
public static IEnumerator RegisteredModules { get; }
Gets a list of registered authentication modules.
A IEnumerator that provides access to the list of registered authentication modules.
This property is read-only.[Note: The System.Net.AuthenticationManager.Register(System.Net.IAuthenticationModule) method adds modules to the list of registered authentication modules, and the System.Net.AuthenticationManager.Unregister(System.Net.IAuthenticationModule) method removes modules from it.]
System.Net.AuthenticationManager Class, System.Net Namespace