Partager via


How to: Provision Connected Data Sources That Generate Anchor Attributes

Connected data sources that generate anchor attributes usually have a primary key from an auto-incremented identity column. The primary key is used as the anchor attribute. To provision objects that will be exported to these connected data sources, assign a temporary unique distinguished name to the attribute. You can manually create this distinguished name based on attributes on the metaverse object, or you can use the NewGuid method to create the temporary distinguished name. When the object is exported to the data source, the data source changes the distinguished name property from the temporary value to the permanent value.

The following examples show how to provision objects that generate anchor attributes.

Public Sub Provision( _
   ByVal mventry As MVEntry) _
   Implements IMVSynchronization.Provision

    Dim ManagementAgent As ConnectedMA  ' Management agent object
    Dim Connectors As Integer           ' Number of connectors under this 
                                        ' management agent
    Dim DN As ReferenceValue            ' Distinguished name attribute
    Dim csentry As CSEntry              ' Connector space entry object

    ' Determine the state of the <tla rid="fim_syncdb_short" /> object.
    If mventry("EmployeeStatus").IsPresent _
        AndAlso mventry("EmployeeStatus").Value.Equals("active") Then

        ' Get the management agent.
        ManagementAgent = mventry.ConnectedMAs("Data Source Assigned DN MA")

        ' Get the number of connectors for this MVEntry object under
        ' this management agent.
        Connectors = ManagementAgent.Connectors.Count

        ' Construct a temporary escaped distinguished name.
        DN = ManagementAgent.EscapeDNComponent(System.Guid.NewGuid().ToString)

        If 0 = Connectors Then
            ' Create a new connector.
            csentry = ManagementAgent.Connectors.StartNewConnector("person")

            ' Assign the temporary escaped distinguished name to the DN property.
            csentry.DN = DN

            ' Add the connector to the connector collection.
            csentry.CommitNewConnector()

        ElseIf 1 = Connectors Then

            ' If the connector already exists and you want to use
            ' this connector, remove the comment from the following line and add 
            ' your code.
            ' csentry = ManagementAgent.Connectors.ByIndex(0)

        Else
            Dim ExceptionMessage As String
            ExceptionMessage = "Multiple connectors on the management agent."
            Throw New UnexpectedDataException(ExceptionMessage)

        End If

   End If
End Sub
void IMVSynchronization.Provision (MVEntry mventry)
{
    ConnectedMA ManagementAgent;  // Management agent object
    int Connectors = 0;           // Number of connectors under this 
                                  // management agent
    ReferenceValue DN;            // Distinguished name attribute
    CSEntry csentry;              // Connector space entry object

    // Determine the state of the <tla rid="fim_syncdb_short" /> object.
    if(mventry["EmployeeStatus"].IsPresent)
    {
        if (mventry["EmployeeStatus"].Value.Equals("active"))
        {

            // Get the management agent.
            ManagementAgent = mventry.ConnectedMAs["Data Source Assigned DN MA"];

            // Get the number of connectors for this MVEntry object under
            // this management agent.
            Connectors = ManagementAgent.Connectors.Count;

            // Construct a temporary escaped distinguished name.
            DN = ManagementAgent.EscapeDNComponent(System.Guid.NewGuid().ToString());

            if(0 == Connectors)
            {

                // Create a new connector.
                csentry = ManagementAgent.Connectors.StartNewConnector("person");

                // Assign the temporary escaped distinguished name to the DN property.
                csentry.DN = DN;

                // Add the connector to the connector collection.
                csentry.CommitNewConnector();
            }

            if (1 == Connectors)
            {
                // If the connector already exists and you want to use
                // this connector, remove the comment from the following line and add 
                // your code.
                // csentry = ManagementAgent.Connectors.ByIndex(0)
            }

            else
            {
                string ExceptionMessage;
                ExceptionMessage = "Multiple connectors on the management agent.";
                throw new UnexpectedDataException(ExceptionMessage);
            }
        }
    }
}

See Also

Reference

StartNewConnector
DN
CommitNewConnector

Concepts

Provisioning Objects in the Connector Space