Share via


Example: CLM Recover Request

The following examples show how to provision a CLM Recover request. The first example demonstrates how to do this with the use of CLMUtils.CreateRecoverRequest. The second shows a more manual approach. Leveraging Utils.TransactionProperties to trigger a recover request can help to ensure that only one request is created. Otherwise, each time CLMUtils.CreateRecoverRequest is called, a new request will be created.

CLMUtils.CreateRecoverRequest

    Sub Provision(ByVal mventry As MVEntry)
        Implements IMVSynchronization.Provision
    
        Try
            If mventry("objectGUID").IsPresent
                And Utils.TransactionProperties(
                "triggerRecover").Equals(True) Then
    
                CLMUtils.CreateRecoverRequest(CLMMA,
                    New Guid(mventry("objectGUID").BinaryValue),
                    "CLM Sample Profile Template")
            End If
        ' Log and rethrow any exception
        Catch ex As Exception
            Logging.Logging.LogException(ex,
                "Provision",
                "Caught exception",
                False)
            Throw
        End Try
    
    End Sub 'IMVSynchronization.Provision
    void IMVSynchronization.Provision (MVEntry mventry)
    {
        try
        {
            if (mventry["objectGUID"].IsPresent &&
                Utils.TransactionProperties["triggerRecover"].Equals(true))
            {
                CLMUtils.CreateRecoverRequest(CLMMA,
                    new Guid(mventry["objectGUID"].BinaryValue),
                    "CLM Sample Profile Template");
            }
        }
        // Log and rethrow any exception
        catch(Exception ex)
        {
            Logging.Logging.LogException(ex,
                "Provision",
                "Caught exception",
                false);
            throw;
        }
    }

Provision Recover Request

    Sub Provision(ByVal mventry As MVEntry)
        Implements IMVSynchronization.Provision
    
        Try
            If mventry("objectGUID").IsPresent And
                Utils.TransactionProperties(
                "triggerRecover").Equals(True) Then
    
                Dim targetCLMMA As ConnectedMA =
                    mventry.ConnectedMAs("CertificateLifecycleManagerMA")
                
                Dim csentry As CSEntry =
                    targetCLMMA.Connectors.StartNewConnector("clmRequest")
                
                csentry.DN = targetCLMMA.EscapeDNComponent("CN=" +
                    Guid.NewGuid().ToString())
                csentry("req_type").IntegerValue = 2
                csentry("req_type_name").Value = "Recover"
                csentry("req_profile_uuid").BinaryValue =
                    New Guid().ToByteArray()
                ' Guid of profile to associate request with
                csentry.CommitNewConnector()
            End If
        
        ' Log and rethrow any exception
        Catch ex As Exception
            Logging.Logging.LogException(ex,
                "Provision",
                "Caught exception",
                False)
            Throw
        End Try
    
    End Sub 'IMVSynchronization.Provision
    void IMVSynchronization.Provision(MVEntry mventry)
    {
        try
        {
            if (mventry["objectGUID"].IsPresent &&
                Utils.TransactionProperties["triggerRecover"].Equals(true))
            {
                ConnectedMA targetCLMMA =
                    mventry.ConnectedMAs["CertificateLifecycleManagerMA"];
    
                CSEntry csentry =
                    targetCLMMA.Connectors.StartNewConnector("clmRequest");
    
                csentry.DN = targetCLMMA.EscapeDNComponent("CN=" +
                    Guid.NewGuid().ToString());
                csentry["req_type"].IntegerValue = 2;
                csentry["req_type_name"].Value = "Recover";
                csentry["req_profile_uuid"].BinaryValue =
                    new Guid(/*Guid of profile to associate request with
                    */).ToByteArray();
                csentry.CommitNewConnector();
            }
        }
    
        // Log and rethrow any exception
        catch (Exception ex)
        {
            Logging.Logging.LogException(ex,
                "Provision",
                "Caught exception",
                false);
            throw;
        }
    }

Send comments about this topic to Microsoft

Build date: 2/16/2009