Bagikan melalui


X509SelectionFlag Enum

Definisi

Menentukan jenis pilihan yang diminta menggunakan SelectFromCollection metode .

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

Bidang

MultiSelection 1

Pilihan ganda. Pengguna dapat menggunakan tombol SHIFT atau CRTL untuk memilih lebih dari satu sertifikat X.509.

SingleSelection 0

Satu pilihan. UI memungkinkan pengguna untuk memilih satu sertifikat X.509.

Contoh

Contoh kode berikut menunjukkan cara menggunakan bendera pemilihan dengan X509Certificate2UI.SelectFromCollection metode . Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk X509Store kelas . Contoh yang lebih besar membuka penyimpanan sertifikat pribadi pengguna saat ini, memungkinkan pengguna untuk memilih sertifikat, lalu menulis informasi sertifikat dan rantai sertifikat ke konsol. Output tergantung pada sertifikat yang dipilih pengguna.

//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)

Keterangan

Bendera ini mewakili satu atau beberapa pilihan sertifikat menggunakan X509Certificate2UI.SelectFromCollection metode .

Berlaku untuk