Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

X509SelectionFlag Enumeration

Specifies the type of selection requested using the X509Certificate2UI.SelectFromCollection method.

Namespace:  System.Security.Cryptography.X509Certificates
Assembly:  System.Security (in System.Security.dll)
public enum X509SelectionFlag
Member nameDescription
MultiSelectionA multiple selection. The user can use the SHIFT or CRTL keys to select more than one X.509 certificate.
SingleSelectionA single selection. The UI allows the user to select one X.509 certificate.

This flag represents either a single or multiple certificate selection using the X509Certificate2UI.SelectFromCollection method.

The following code example demonstrates how to use the selection flag with the X509Certificate2UI.SelectFromCollection method. This code example is part of a larger example provided for the X509Store class. The larger example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects.

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, 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.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.