Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AuthenticationManager.Unregister Method (IAuthenticationModule)

Removes the specified authentication module from the list of registered modules.

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

public static void Unregister (
	IAuthenticationModule authenticationModule
)
public static void Unregister (
	IAuthenticationModule authenticationModule
)
public static function Unregister (
	authenticationModule : IAuthenticationModule
)
Not applicable.

Parameters

authenticationModule

The IAuthenticationModule to remove from the list of registered modules.

Exception typeCondition

ArgumentNullException

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

InvalidOperationException

The specified IAuthenticationModule is not registered.

The Unregister method removes the specified authentication module from the list of authentication modules called by the Authenticate method. The module must have been added to the list using the Register method before it can be removed from the list.

The following example uses the Unregister method to remove the specified authentication module from the list of registered modules. 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.
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 = string.Empty;
    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;
}

// 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 Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.