[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ms-cryptoapi
Subject:    Re: REPOST:HELP: CertFindCertificateInStore
From:       DolanP () DELUXE-DATA ! CO ! UK
Date:       1999-08-27 13:48:38
[Download RAW message or body]


Roman,

I have just made this up, so a little trial and error may be in order:

     CERT_RDN       certRDN;
     CERT_RDN_ATTR  certRDNAttr;
     PCCERT_CONTEXT pCertContext = NULL;

     // Assumes hCertStore has been setup.

     // Assumes Organizational Unit is an ASCII string.
     char           szOU[] = ?????;

     // Setup OU = xxx as our search criteria.
     certRDNAttr.pszObjId = szOID_ORGANIZATION_UNIT_NAME;
     certRDNAttr.dwValueType = CERT_RDN_PRINTABLE_STRING;
     certRDNAttr.Value.cbData = strlen(szOU);
     certRDNAttr.Value.pbData = szOU;

     // Assume only one attribute
     certRDN.cRDNAttr = 1;
     certRDN.rgRDNAttr = &certRDNAttr;

     // Iterate through ALL certificates that match on required Subject
Organizational Unit,
     // that is, they could be from different Issuers.
     while (   (pCertContext = CertFindCertificateInStore(
               hCertStore,
                X509_ASN_ENCODING,
               NULL,
               CERT_FIND_SUBJECT_ATTR,
               (const void *)&certRDN,
               pCertContext)
          )  !=   NULL )
     {
          // Do something with certificate pointed to by pCertContext.
          // ...
     }

     // Just in case we break from the while loop
     if (pCertContext != NULL)
          CertFreeCertificateContext(pCertContext);


Regards,
Patrick Dolan.





"Dr. Roman Becker" <rbec@EASY.DE> on 27/08/99 10:39:21

Please respond to Microsoft Cryptographic API
      <CryptoAPI@DISCUSS.MICROSOFT.COM>

To:   CryptoAPI@DISCUSS.MICROSOFT.COM
cc:    (bcc: Patrick Dolan/UK/Deluxe Data/Deluxe Corporation)
Subject:  REPOST:HELP: CertFindCertificateInStore




Hello,

could anyone provide me with a code snippet that shows how to use
CertFindCertificateInStore with dwFindType = CERT_FIND_SUBJECT_ATTR. I
would
just like to dig up all certificates in a store that belong to a specific
organizational unit(OU=<xxx>). I found some postings in the archives of '97
that did not come to a final conclusion. Any help is highly appreciated.

Dr. Roman Becker
EASY SOFTWARE AG
SOFTWARE FOR DOCUMENTS
Rennweg 60
D-56232 Andernach
Tel. 02632/405-924

 mailto:rbec@easy.de

 http://www.easy.de

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

----------------------------------------------------------------
Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
contains important info including how to unsubscribe.  Save time, search
the archives at http://discuss.microsoft.com/archives/index.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic