Export (0) Print
Expand All

AuthenticationManager.Register Method

Registers an authentication module with the authentication manager.

Namespace: System.Net
Assembly: System (in system.dll)

'Declaration
Public Shared Sub Register ( _
	authenticationModule As IAuthenticationModule _
)
'Usage
Dim authenticationModule As IAuthenticationModule

AuthenticationManager.Register(authenticationModule)
public static void Register (
	IAuthenticationModule authenticationModule
)
public static function Register (
	authenticationModule : IAuthenticationModule
)

Parameters

authenticationModule

The IAuthenticationModule to register with the authentication manager.

Exception typeCondition

ArgumentNullException

authenticationModule is a null reference (Nothing in Visual Basic).

The Register method adds authentication modules to the end of the list of modules called by the Authenticate method. Authentication modules are called in the order in which they were added to the list. If a module with the same AuthenticationType is already registered, this method removes the registered module and adds authenticationModule to the end of the list.

The following example registers an authentication module with the authentication manager. For a complete example, refer to the AuthenticationManager class.

 ' This is the program entry point. It allows the user to enter 
 ' her credentials and the Internet resource (Web page) to access.
 ' It also unregisters the standard and registers the customized basic 
 ' authentication.
Private Overloads Shared Sub Main(ByVal args() As String)

  If args.Length < 4 Then
    showusage()
  Else

    ' Read the user's credentials.
    uri = args(1)
    username = args(2)
    password = args(3)

    If args.Length = 4 Then
      domain = String.Empty
      ' If the domain exists, store it. Usually the domain name
      ' is by default the name of the server hosting the Internet
      ' resource.
    Else
      domain = args(5)
    End If
    ' Unregister the standard Basic authentication module.
    AuthenticationManager.Unregister("Basic")

    ' Instantiate the custom Basic authentication module.
    Dim customBasicModule As New CustomBasic()

    ' Register the custom Basic authentication module.
    AuthenticationManager.Register(customBasicModule)

    ' Display registered Authorization modules.
    displayRegisteredModules()

    ' Read the specified page and display it on the console.
    getPage(uri)
  End If
  Return
End Sub 'Main

// This is the program entry point. It allows the user to enter 
// her credentials and the Internet resource (Web page) to access.
// It also unregisters the standard and registers the customized basic 
// authentication.
public static void main(String[] args)
{
    if (args.length < 3) {
        Showusage();
    }
    else {
        // Read the user's credentials.
        uri = args[0];
        username = args[1];
        password = args[2];
        if (args.length == 3) {
            domain = "";
        }                
        else {
            // If the domain exists, store it. Usually the domain name
            // is by default the name of the server hosting the Internet
            // resource.
            domain = args[3];
        }

        // Unregister the standard Basic authentication module.
        AuthenticationManager.Unregister("Basic");

        // Instantiate the custom Basic authentication module.
        CustomBasic customBasicModule = new CustomBasic();

        // Register the custom Basic authentication module.
        AuthenticationManager.Register(customBasicModule);

        // Display registered Authorization modules.
        DisplayRegisteredModules();

        // Read the specified page and display it on the console.
        GetPage(uri);
    }
    return;
} //main

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft