Export (0) Print
Expand All

AuthenticationManager::Register Method

Registers an authentication module with the authentication manager.

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

public:
static void Register(
	IAuthenticationModule^ authenticationModule
)

Parameters

authenticationModule
Type: System.Net::IAuthenticationModule

The IAuthenticationModule to register with the authentication manager.

ExceptionCondition
ArgumentNullException

authenticationModule is nullptr.

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. 
   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;
   }

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Show:
© 2014 Microsoft