IEnumCERTVIEWEXTENSION::GetFlags method

The GetFlags method retrieves the policy and origin flags of the current extension in the extension-enumeration sequence.

Both the policy and origin flags are returned in one variable, and bitmasks are provided to retrieve the individual values.

Syntax


HRESULT GetFlags(
  [out] LONG *pFlags
);

Parameters

pFlags [out]

A pointer to a LONG type that contains the policy and origin flags of the extension. This method fails if the pFlags parameter is set to NULL.

Return value

C++

If the method succeeds, the method returns S_OK.

If the method fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.

VB

The return value represents the policy and origin values of the extension.

Remarks

This method is used to retrieve the policy and origin flags of the extension currently referenced by the extension-enumeration sequence.

Policy flags provide information about the certificate extension and can be set by the policy module.

Origin flags indicate the module that set the certificate extension and are set only by the server engine.

One or more policy flags can be returned from an extension. The following are predefined policy flags.

Policy flag valueExplanation
EXTENSION_CRITICAL_FLAGThis is a critical extension.
EXTENSION_DISABLE_FLAGExtension will not be used.

 

One of the following origin flags can also be returned.

Origin flag valueExplanation
EXTENSION_ORIGIN_REQUESTThe extension was extracted from an array of extensions stored in the szOID_CERT_EXTENSIONS (1.3.6.1.4.1.311.2.1.14) or szOID_RSA_certExtensions (1.2.840.113549.1.9.14) attribute of a PKCS #10 request.
EXTENSION_ORIGIN_POLICYThe policy module set the extension.
EXTENSION_ORIGIN_ADMINThe administrator set the extension.
EXTENSION_ORIGIN_SERVERThe server engine set the extension.
EXTENSION_ORIGIN_RENEWALCERTThe extension was extracted from the certificate stored in the szOID_RENEWAL_CERTIFICATE (1.3.6.1.4.1.311.13.1) attribute of a PKCS #10 renewal request.
EXTENSION_ORIGIN_IMPORTEDCERTThe extension was extracted from an imported certificate (the certificate was passed to ICertAdmin::ImportCertificate).
EXTENSION_ORIGIN_PKCS7The extension was extracted from an array of extensions stored in the szOID_CERT_EXTENSIONS (1.3.6.1.4.1.311.2.1.14) or szOID_RSA_certExtensions (1.2.840.113549.1.9.14) attribute of a PKCS #7 request.

 

Predefined masks are provided for ease of use in determining which flags are set in the return value. The following masks are provided.

Mask valueExplanation
EXTENSION_POLICY_MASKThis value (0x0000FFFF) is used to examine policy flags.
EXTENSION_ORIGIN_MASKThis value (0x000F0000) is used to examine origin flags.

 

If the extension-enumeration sequence is not referencing a valid extension, GetFlags will fail. Use one of the following methods to navigate through the enumeration:

Examples


HRESULT  hr;
LONG     ExtFlags;

// pEnumExt is previously instantiated IEnumCERTVIEWEXTENSION object
hr = pEnumExt->GetFlags(&ExtFlags);
if (S_OK != hr)
    printf("Failed GetFlags - %x\n", hr);
else
{
    LONG ExtPol, ExtOrig;

    ExtPol = ExtFlags & EXTENSION_POLICY_MASK;
    if (ExtPol & EXTENSION_CRITICAL_FLAG)
        printf("The extension is critical\n");
    if (ExtPol & EXTENSION_DISABLE_FLAG )
        printf("The extension is disabled\n");

    ExtOrig = ExtFlags & EXTENSION_ORIGIN_MASK;
    switch (ExtOrig)
    {
        case EXTENSION_ORIGIN_REQUEST:
            printf("Extension originated by PKCS #10 Request\n");
            break;
        case EXTENSION_ORIGIN_POLICY:
            printf("Extension originated by Policy\n");
            break;
        case EXTENSION_ORIGIN_ADMIN:
            printf("Extension originated by Admin\n");
            break;
        case EXTENSION_ORIGIN_SERVER:
            printf("Extension originated by Server\n");
            break;
        case EXTENSION_ORIGIN_RENEWALCERT:
            printf("Extension originated by Renewal Request\n");
            break;
        case EXTENSION_ORIGIN_IMPORTEDCERT:
            printf("Extension originated by an imported "
                "certificate\n");
            break;
        case EXTENSION_ORIGIN_PKCS7:
            printf("Extension originated by PKCS #7 Request\n");
            break;
        default:
            printf("Unknown extension origin\n");
            break;
    }
}

Requirements

Minimum supported client

None supported

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Certview.h (include Certsrv.h)

Library

Certidl.lib

DLL

Certadm.dll

IID

IID_IEnumCERTVIEWEXTENSION is defined as e7dd1466-7653-11d1-9bde-00c04fb683fa

See also

IEnumCERTVIEWEXTENSION
IEnumCERTVIEWEXTENSION::GetName
IEnumCERTVIEWEXTENSION::GetValue
IEnumCERTVIEWEXTENSION::Next

 

 

Show: