AuthenticationManager.Register(IAuthenticationModule) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Registriert ein Authentifizierungsmodul beim Authentifizierungs-Manager.
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)
Parameter
- authenticationModule
- IAuthenticationModule
Der IAuthenticationModule zum Registrieren beim Authentifizierungs-Manager.
Ausnahmen
authenticationModule ist null.
Beispiele
Im folgenden Beispiel wird ein Authentifizierungsmodul mit dem Authentifizierungs-Manager registriert. Ein vollständiges Beispiel finden Sie in der AuthenticationManager Klasse.
// 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
Hinweise
Die Register Methode fügt am Ende der Liste der von der Authenticate Methode aufgerufenen Module Authentifizierungsmodule hinzu. Authentifizierungsmodule werden in der Reihenfolge aufgerufen, in der sie der Liste hinzugefügt wurden. Wenn ein Modul mit demselben AuthenticationType bereits registriert ist, entfernt diese Methode das registrierte Modul und fügt am Ende der Liste hinzu authenticationModule .