Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to prevent overwriting of certificate on adding the same one fetched from various nodes of the Active Directory using LDAP Server to the Windows Certificate Store?

I am fetching the certificates from Active Directory using LDAP Server.The issue is that if there are various nodes (say CN=A,CN=B etc) and if same certificate exists in each of the nodes,on adding to the windows certificate personal store it gets overwrite.

I am adding the certificate to the store as per below code.

C#
// Convert the Filename to an X509 Certificate
                                      X509Certificate2 cert = new X509Certificate2(cerFilePath);
                                      // Get the server certificate store and pass to Personal Certificate Store(Check wih Certmgr.msc in Run)
                                      X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
                                      store.Open(OpenFlags.ReadWrite);
                                      //Add the Certificate File to Windows Cetificate Store
                                      store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(cerFilePath)));
                                      store.Close();</pre>
Posted
Updated 3-Nov-15 20:59pm
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900