Udostępnij za pośrednictwem


X509SelectionFlag Wyliczenie

Definicja

Określa typ wyboru żądanego SelectFromCollection przy użyciu metody .

public enum class X509SelectionFlag
public enum X509SelectionFlag
type X509SelectionFlag = 
Public Enum X509SelectionFlag
Dziedziczenie
X509SelectionFlag

Pola

MultiSelection 1

Wybór wielokrotny. Użytkownik może użyć klawiszy SHIFT lub CRTL, aby wybrać więcej niż jeden certyfikat X.509.

SingleSelection 0

Pojedynczy wybór. Interfejs użytkownika umożliwia użytkownikowi wybranie jednego certyfikatu X.509.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać flagi wyboru z X509Certificate2UI.SelectFromCollection metodą . Ten przykład kodu jest częścią większego przykładu podanego X509Store dla klasy. Większy przykład otwiera osobisty magazyn certyfikatów bieżącego użytkownika, umożliwia użytkownikowi wybranie certyfikatu, a następnie zapisanie informacji o certyfikacie i łańcuchu certyfikatów w konsoli programu . Dane wyjściowe zależą od certyfikatu wybranego przez użytkownika.

//Create new X509 store from local certificate store.
X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser );
store->Open( static_cast<OpenFlags>(OpenFlags::OpenExistingOnly | OpenFlags::ReadWrite) );

//Output store information.
Console::WriteLine( "Store Information" );
Console::WriteLine( "Number of certificates in the store: {0}", store->Certificates->Count );
Console::WriteLine( "Store location: {0}", store->Location );
Console::WriteLine( "Store name: {0} {1}", store->Name, Environment::NewLine );

//Put certificates from the store into a collection so user can select one.
X509Certificate2Collection ^ fcollection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
X509Certificate2Collection ^ collection = X509Certificate2UI::SelectFromCollection(fcollection, "Select an X509 Certificate","Choose a certificate to examine.",X509SelectionFlag::SingleSelection);
X509Certificate2 ^ certificate = collection[ 0 ];
X509Certificate2UI::DisplayCertificate(certificate);
    //Create new X509 store from local certificate store.
    X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
    store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);

    //Output store information.
    Console.WriteLine ("Store Information");
    Console.WriteLine ("Number of certificates in the store: {0}", store.Certificates.Count);
    Console.WriteLine ("Store location: {0}", store.Location);
    Console.WriteLine ("Store name: {0} {1}", store.Name, Environment.NewLine);

    //Put certificates from the store into a collection so user can select one.
    X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates;
    X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection);
    X509Certificate2 certificate = collection[0];
    X509Certificate2UI.DisplayCertificate(certificate);
'Create new X509 store from local certificate store.
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.OpenExistingOnly Or OpenFlags.ReadWrite)

'Output store information.
Console.WriteLine("Store Information")
Console.WriteLine("Number of certificates in the store: {0}", store.Certificates.Count)
Console.WriteLine("Store location: {0}", store.Location)
Console.WriteLine("Store name: {0} {1}", store.Name, Environment.NewLine)

'Put certificates from the store into a collection so user can select one.
Dim fcollection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)
Dim collection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection)
Dim certificate As X509Certificate2 = collection(0)
X509Certificate2UI.DisplayCertificate(certificate)

Uwagi

Ta flaga reprezentuje pojedynczy lub wielokrotny wybór certyfikatu X509Certificate2UI.SelectFromCollection przy użyciu metody .

Dotyczy