This documentation is archived and is not being maintained.

AuthenticationManager.Unregister Method (IAuthenticationModule)

.NET Framework 1.1

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

[Visual Basic]
Overloads Public Shared Sub Unregister( _
   ByVal authenticationModule As IAuthenticationModule _
)
[C#]
public static void Unregister(
 IAuthenticationModule authenticationModule
);
[C++]
public: static void Unregister(
 IAuthenticationModule* authenticationModule
);
[JScript]
public static function Unregister(
   authenticationModule : IAuthenticationModule
);

Parameters

authenticationModule
The IAuthenticationModule to remove from the list of registered modules.

Exceptions

Exception Type Condition
ArgumentNullException authenticationModule is a null reference (Nothing in Visual Basic).
InvalidOperationException The specified IAuthenticationModule is not registered.

Remarks

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.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
' 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

[C#] 
// 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;
}

[C++] 
// 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[] = Environment::GetCommandLineArgs();


    if (args->Length < 4)
        showusage();
    else 
    {    

        // Read the user's credentials.
        uri = args[1];
        username = args[2];
        password = args[3];

        if (args->Length == 4)
            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[4];

        // Unregister the standard Basic authentication module.
        AuthenticationManager::Unregister(S"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;
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

.NET Framework Security: 

See Also

AuthenticationManager Class | AuthenticationManager Members | System.Net Namespace | AuthenticationManager.Unregister Overload List

Show: