System.Net.AuthenticationManager Class

Assembly: System.dll
Namespace: System.Net
Summary
Manages the authentication modules called during the client authentication process.
C# Syntax:
public class AuthenticationManager
Remarks
AuthenticationManager is a static class that manages the authentication modules that an application uses. When a request is made to protected resources, the AuthenticationManager calls the AuthenticationManager.Authenticate method to get an Authorization instance to use in subsequent requests.

The AuthenticationManager queries each registered authentication module by calling the IAuthenticationModule.Authenticate method for each module. The first authentication module to return an Authorization instance is used to authenticate the request.

Modules that provide the basic, digest, negotiate, NTLM, and Kerberos authentication types are registered with the AuthenticationManager by default. Additional authentication modules that implement the IAuthenticationModule interface can be added using the AuthenticationManager.Register method. Authentication modules are called in the order in which they were added to the list.



Note The Kerberos and negotiate authentication type is not supported on Windows 95/98 or Windows NT 4.0.
See also:
System.Net Namespace

System.Net.AuthenticationManager Member List:

Public Properties
RegisteredModules Read-only

Gets a list of authentication modules that are registered with the authentication manager.
Public Methods
Authenticate Calls each registered authentication module to find the first module that can respond to the authentication request.
Equals
(inherited from System.Object)
See base class member description: System.Object.Equals

Derived from System.Object, the primary base class for all objects.
GetHashCode
(inherited from System.Object)
See base class member description: System.Object.GetHashCode

Derived from System.Object, the primary base class for all objects.
GetType
(inherited from System.Object)
See base class member description: System.Object.GetType

Derived from System.Object, the primary base class for all objects.
PreAuthenticate Preauthenticates a request.
Register Registers an authentication module with the authentication manager.
ToString
(inherited from System.Object)
See base class member description: System.Object.ToString

Derived from System.Object, the primary base class for all objects.
Unregister Overloaded:
Unregister(IAuthenticationModule authenticationModule)

Removes the specified authentication module from the list of registered modules.
Unregister Overloaded:
Unregister(string authenticationScheme)

Removes authentication modules with the specified authentication scheme from the list of registered modules.
Protected Methods
Finalize
(inherited from System.Object)
See base class member description: System.Object.Finalize

Derived from System.Object, the primary base class for all objects.
MemberwiseClone
(inherited from System.Object)
See base class member description: System.Object.MemberwiseClone

Derived from System.Object, the primary base class for all objects.

Hierarchy:


System.Net.AuthenticationManager Member Details

Property: RegisteredModules (read-only)
Summary
Gets a list of authentication modules that are registered with the authentication manager.
C# Syntax:
public static IEnumerator RegisteredModules {get;}
Remarks
The AuthenticationManager.RegisteredModules property provides an IEnumerator instance that enables the list of registered authentication modules to be read. The AuthenticationManager.Register method adds modules to the list, and the AuthenticationManager.Unregister method removes modules from it.

Return to top


Method: Authenticate(
   string challenge,
   WebRequest request,
   ICredentials credentials
)
Summary
Calls each registered authentication module to find the first module that can respond to the authentication request.
C# Syntax:
public static Authorization Authenticate(
   string challenge,
   WebRequest request,
   ICredentials credentials
);
Parameters:

challenge

The challenge returned by the Internet resource.

request

The WebRequest that initiated the authentication challenge.

credentials

The ICredentials associated with this request.

Return Value:
An instance of the Authorization class containing the result of the authorization attempt. If there is no authentication module to respond to the challenge, this method returns null.
Exceptions
Exception Type Condition
ArgumentNullException challenge is null.

-or-

request is null.

-or-

credentials is null.

Remarks
The AuthenticationManager.Authenticate method calls the IAuthenticationModule.Authenticate method on each registered authentication module until one of the module responds with an Authorization instance.

The first Authorization instance returned is used to authenticate the request. If no authentication module can authenticate the request, the AuthenticationManager.Authenticate method returns null.

Authentication modules are called in the order in which they are registered with the AuthenticationManager.

Return to top


Method: Equals(
   object obj
)
Inherited
See base class member description: System.Object.Equals
C# Syntax:
public virtual bool Equals(
   object obj
);

For more information on members inherited from System.Object click on the link above.

Return to top


Method: Finalize()
Inherited
See base class member description: System.Object.Finalize
C# Syntax:
~AuthenticationManager();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetHashCode()
Inherited
See base class member description: System.Object.GetHashCode
C# Syntax:
public virtual int GetHashCode();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: GetType()
Inherited
See base class member description: System.Object.GetType
C# Syntax:
public Type GetType();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: MemberwiseClone()
Inherited
See base class member description: System.Object.MemberwiseClone
C# Syntax:
protected object MemberwiseClone();

For more information on members inherited from System.Object click on the link above.

Return to top


Method: PreAuthenticate(
   WebRequest request,
   ICredentials credentials
)
Summary
Preauthenticates a request.
C# Syntax:
public static Authorization PreAuthenticate(
   WebRequest request,
   ICredentials credentials
);
Parameters:

request

A WebRequest to an Internet resource.

credentials

The ICredentials associated with the request.

Return Value:
An instance of the Authorization class if the request can be preauthenticated; otherwise, null. If credentials is null, this method returns null.
Exceptions
Exception Type Condition
ArgumentNullException request is null.
Remarks
If the authentication module can preauthenticate the request, the PreAuthenticate method returns an Authentication instance and sends the authorization informaiton to the server preemptively instead of waiting for the resource to issue a challenge. This behavior is outlined in section 3.3 of RFC 2617 (HTTP Authentication: Basic and Digest Access Authentication). Authentication modules that support preauthentication allow clients to improve server efficiency by avoiding extra round trips caused by authentication challenges.

Authorization modules that can preauthenticate requests set the IAuthenticationModule.CanPreAuthenticate property to true.

Return to top


Method: Register(
   IAuthenticationModule authenticationModule
)
Summary
Registers an authentication module with the authentication manager.
C# Syntax:
public static void Register(
   IAuthenticationModule authenticationModule
);
Parameters:

authenticationModule

The IAuthenticationModule to register with the authentication manager.

Exceptions
Exception Type Condition
ArgumentNullException authenticationModule is null.
InvalidOperationException A module for this authentication scheme has already been registered.
Remarks
The AuthenticationManager.Register method adds authentication modules to the end of the list of modules called by the AuthenticationManager.Authenticate method. Authentication modules are called in the order in which they were added to the list.

Return to top


Method: ToString()
Inherited
See base class member description: System.Object.ToString
C# Syntax:
public virtual string ToString();

For more information on members inherited from System.Object click on the link above.

Return to top


Overloaded Method: Unregister(
   IAuthenticationModule authenticationModule
)
Summary
Removes the specified authentication module from the list of registered modules.
C# Syntax:
public static void Unregister(
   IAuthenticationModule authenticationModule
);
Parameters:

authenticationModule

The IAuthentication module to remove.

Exceptions
Exception Type Condition
ArgumentNullException authenticationModule is null.
InvalidOperationException The specified IAuthenticationModule was never registered.
Remarks
The AuthenticationManager.Unregister method removes the specified authentication module from the list of authentication modules called by the AuthenticationManager.Authenticate method. The module must have been added to the list using the AuthenticationManager.Register method before it can be removed from the list.

Return to top


Overloaded Method: Unregister(
   string authenticationScheme
)
Summary
Removes authentication modules with the specified authentication scheme from the list of registered modules.
C# Syntax:
public static void Unregister(
   string authenticationScheme
);
Parameters:

authenticationScheme

The authentication scheme of the module to remove.

Exceptions
Exception Type Condition
ArgumentNullException authenticationScheme is null.
InvalidOperationException A module for this authentication scheme was never registered.
Remarks
The AuthenticationManager.Unregister method removes the authentication module with the specified authentication scheme from the list of authentication modules called by the AuthenticationManager.Authenticate method. The module must have been added to the list using the AuthenticationManager.Register method before it can be removed from the list.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.