AuthenticationManager.Unregister 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從登錄模組的清單移除驗證模組。
多載
Unregister(IAuthenticationModule) |
從登錄模組的清單移除指定的驗證模組。 |
Unregister(String) |
從登錄模組的清單移除具有指定驗證配置的驗證模組。 |
Unregister(IAuthenticationModule)
從登錄模組的清單移除指定的驗證模組。
public:
static void Unregister(System::Net::IAuthenticationModule ^ authenticationModule);
public static void Unregister (System.Net.IAuthenticationModule authenticationModule);
static member Unregister : System.Net.IAuthenticationModule -> unit
Public Shared Sub Unregister (authenticationModule As IAuthenticationModule)
參數
- authenticationModule
- IAuthenticationModule
IAuthenticationModule,其將從註冊的模組清單移除。
例外狀況
authenticationModule
為 null
。
範例
下列範例會 Unregister 使用 方法來從已註冊的模組清單中移除指定的驗證模組。 如需完整的範例,請參閱 AuthenticationManager 類別。
// 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
備註
方法 Unregister 會從方法所 Authenticate 呼叫的驗證模組清單中移除指定的驗證模組。 必須先使用 Register 方法將模組新增至清單中,才能從清單中移除該模組。
適用於
Unregister(String)
從登錄模組的清單移除具有指定驗證配置的驗證模組。
public:
static void Unregister(System::String ^ authenticationScheme);
public static void Unregister (string authenticationScheme);
static member Unregister : string -> unit
Public Shared Sub Unregister (authenticationScheme As String)
參數
- authenticationScheme
- String
要移除之模組的驗證配置。
例外狀況
authenticationScheme
為 null
。
這個驗證配置的模組未註冊。
範例
下列範例會 Unregister 使用 方法,從已註冊的模組清單中移除具有指定驗證配置的驗證模組。
IEnumerator^ registeredModules = AuthenticationManager::RegisteredModules;
// Display all the modules that are already registered with the system.
DisplayAllModules();
registeredModules->Reset();
registeredModules->MoveNext();
// Get the first Authentication module registered with the system.
IAuthenticationModule^ authenticationModule1 = dynamic_cast<IAuthenticationModule^>(registeredModules->Current);
// Call the UnRegister() method to unregister the first authentication module from the system.
String^ authenticationScheme = authenticationModule1->AuthenticationType;
AuthenticationManager::Unregister( authenticationScheme );
Console::WriteLine( "\nSuccessfully unregistered '{0}'.", authenticationModule1 );
// Display all modules to see that the module was unregistered.
DisplayAllModules();
IEnumerator registeredModules = AuthenticationManager.RegisteredModules;
// Display all the modules that are already registered with the system.
DisplayAllModules();
registeredModules.Reset();
registeredModules.MoveNext();
// Get the first Authentication module registered with the system.
IAuthenticationModule authenticationModule1 = (IAuthenticationModule)registeredModules.Current;
// Call the UnRegister() method to unregister the first authentication module from the system.
String authenticationScheme = authenticationModule1.AuthenticationType;
AuthenticationManager.Unregister(authenticationScheme);
Console.WriteLine("\nSuccessfully unregistered '{0}",authenticationModule1+"'.");
// Display all modules to see that the module was unregistered.
DisplayAllModules();
Dim registeredModules As IEnumerator = AuthenticationManager.RegisteredModules
DisplayAllModules()
registeredModules.Reset()
registeredModules.MoveNext()
'Get the first Authentication module registered with the system
Dim authenticationModule1 As IAuthenticationModule = CType(registeredModules.Current, IAuthenticationModule)
'Call the UnRegister method to unregister the first authentication module from the system.
Dim authenticationScheme As [String] = authenticationModule1.AuthenticationType
AuthenticationManager.Unregister(authenticationScheme)
Console.WriteLine(ControlChars.Cr + "Successfully unregistered {0}", authenticationModule1)
'Display all modules to see that the module was unregistered.
DisplayAllModules()
'Call the Register method to register authenticationModule1 module again.
AuthenticationManager.Register(authenticationModule1)
Console.WriteLine(ControlChars.Cr + "Successfully re-registered {0}", authenticationModule1)
'Display the modules to verify that 'authenticationModule1' has been registered again.
DisplayAllModules()
備註
Unregister方法會從方法所呼叫Authenticate的驗證模組清單中,移除具有指定驗證配置的驗證模組。 必須先使用 Register 方法將模組新增至清單中,才能從清單中移除該模組。