M
Mike J. Bruno
Guest
I am attempting to write a program that can query a Microsoft CA for certificates which were revoked after a given date. I was able to instantiate a CCertView object, however, I'm not sure how to pass the date parameter to the SetRestriction method, which is documented here.
The method requires 4 variables:
HRESULT SetRestriction(
LONG ColumnIndex,
LONG SeekOperator,
LONG SortOrder,
const VARIANT *pvarValue
);
The parameter I'm having trouble with is *pvarValue. I confirmed that I can pass in a reference to an int if I want to filter based on a simple column (such as request ID). However, I need to pass in a date value.
Here's what I have so far:
CCertView cView = new CCertView();
//Establish the connection to the CA
cView.OpenConnection(@"certserver.contoso.com\Contoso Issuing CA");
//Indicate which columns that I want to appear in my results view
cView.SetResultColumnCount(4);
cView.SetResultColumn(ADCS_COL_SerialNumber);
cView.SetResultColumn(ADCS_COL_CommonName);
cView.SetResultColumn(ADCS_COL_Request_Disposition);
cView.SetResultColumn(ADCS_COL_Request_RevokedEffectiveWhen);
//First, I'm going to filter the results for all REVOKED certificates (Disposition=21)
object dispositionRevoked = 21;
//Then, I want to filter further to isolate only certs that were revoked on or after 7/20/18
object filterDate = "7/20/2014";
//Here I set the first filter (Disposition=21). This works.
cView.SetRestriction(ADCS_COL_Request_Disposition, CVR_SEEK_EQ, CVR_SORT_ASCEND, ref dispositionRevoked);
//This is where I'm attempting to define the date filter. This does NOT work.
cView.SetRestriction(ADCS_COL_Request_RevokedWhen, CVR_SEEK_GE, CVR_SORT_ASCEND, ref filterDate);
When I run the program, I receive the following exception:
When I run the program, I receive the following exception:
>getRevoked.exe
Unhandled Exception: System.ArgumentException: CCertView::SetRestriction: The
parameter is incorrect. 0x80070057 (WIN32:87)
at CERTADMINLib.ICertView2.SetRestriction(Int32 ColumnIndex, Int32 SeekOperator, Int32 SortOrder, Object& pvarValue)
at getRevoked.Program.Main(String[] args)
Continue reading...
The method requires 4 variables:
HRESULT SetRestriction(
LONG ColumnIndex,
LONG SeekOperator,
LONG SortOrder,
const VARIANT *pvarValue
);
The parameter I'm having trouble with is *pvarValue. I confirmed that I can pass in a reference to an int if I want to filter based on a simple column (such as request ID). However, I need to pass in a date value.
Here's what I have so far:
CCertView cView = new CCertView();
//Establish the connection to the CA
cView.OpenConnection(@"certserver.contoso.com\Contoso Issuing CA");
//Indicate which columns that I want to appear in my results view
cView.SetResultColumnCount(4);
cView.SetResultColumn(ADCS_COL_SerialNumber);
cView.SetResultColumn(ADCS_COL_CommonName);
cView.SetResultColumn(ADCS_COL_Request_Disposition);
cView.SetResultColumn(ADCS_COL_Request_RevokedEffectiveWhen);
//First, I'm going to filter the results for all REVOKED certificates (Disposition=21)
object dispositionRevoked = 21;
//Then, I want to filter further to isolate only certs that were revoked on or after 7/20/18
object filterDate = "7/20/2014";
//Here I set the first filter (Disposition=21). This works.
cView.SetRestriction(ADCS_COL_Request_Disposition, CVR_SEEK_EQ, CVR_SORT_ASCEND, ref dispositionRevoked);
//This is where I'm attempting to define the date filter. This does NOT work.
cView.SetRestriction(ADCS_COL_Request_RevokedWhen, CVR_SEEK_GE, CVR_SORT_ASCEND, ref filterDate);
When I run the program, I receive the following exception:
When I run the program, I receive the following exception:
>getRevoked.exe
Unhandled Exception: System.ArgumentException: CCertView::SetRestriction: The
parameter is incorrect. 0x80070057 (WIN32:87)
at CERTADMINLib.ICertView2.SetRestriction(Int32 ColumnIndex, Int32 SeekOperator, Int32 SortOrder, Object& pvarValue)
at getRevoked.Program.Main(String[] args)
Continue reading...