AuthenticationManager.Register(IAuthenticationModule) Metoda

Definicja

Rejestruje moduł uwierzytelniania w menedżerze uwierzytelniania.

public:
 static void Register(System::Net::IAuthenticationModule ^ authenticationModule);
public static void Register (System.Net.IAuthenticationModule authenticationModule);
static member Register : System.Net.IAuthenticationModule -> unit
Public Shared Sub Register (authenticationModule As IAuthenticationModule)

Parametry

authenticationModule
IAuthenticationModule

Element do zarejestrowania IAuthenticationModule się w menedżerze uwierzytelniania.

Wyjątki

authenticationModule to null.

Przykłady

Poniższy przykład rejestruje moduł uwierzytelniania w menedżerze uwierzytelniania. Pełny przykład można znaleźć w AuthenticationManager klasie .

// 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.
static void Main()
{
   array<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; // If the domain exists, store it. Usually the domain name
      else
               domain = args[ 4 ];

      
      // is by default the name of the server hosting the Internet
      // resource.
      // Unregister the standard Basic authentication module.
      AuthenticationManager::Unregister( "Basic" );
      
      // Instantiate the custom Basic authentication module.
      CustomBasic^ customBasicModule = gcnew 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 = 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.
  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
End Class

Uwagi

Metoda Register dodaje moduły uwierzytelniania na końcu listy modułów wywoływanych przez metodę Authenticate . Moduły uwierzytelniania są wywoływane w kolejności, w której zostały dodane do listy. Jeśli moduł o tej samej nazwie AuthenticationType jest już zarejestrowany, ta metoda usuwa zarejestrowany moduł i dodaje authenticationModule go na końcu listy.

Dotyczy