How to: Provision LDAP-Based Connected Data Sources

Lightweight Directory Access Protocol (LDAP)-based connected data sources require a unique distinguished name for each object. You can use the following code examples to provision the connector space for these management agents:

  • Management agent for Active Directory Domain Services (AD DS)

  • Management agent for Active Directory Application Mode (ADAM)

  • Management agent for Directory Services Markup Language for Windows (DSML) 2.0

  • Management agent for Microsoft Exchange Server 5.5

  • Management agent for Exchange Server 5.5 (bridgehead server)

  • Management agent for LDAP Data Interchange Format (LDIF)

  • Management agent for Novell eDirectory 8.6.2 and 8.7

  • Management agent for Sun ONE Directory Server 4.1x and 5.x (formerly iPlanet Directory Server) and Netscape Directory Server 4.1 and 6.01

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

   Dim ManagementAgent As ConnectedMA  ' Management agent object
   Dim Connectors As Integer           ' Management agent connectors
   Dim DN As ReferenceValue            ' Distinguished name attribute
   Dim Container As String             ' Container name
   Dim RDN As String                   ' Relative distinguished name strings
   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 connectors.
      ManagementAgent = mventry.ConnectedMAs("LDAP-based MA")
      Connectors = ManagementAgent.Connectors.Count

     ' Construct the distinguished name.
      Container = "CN=users,DC=fabrikam,DC=com"
      RDN = "CN=" & mventry("cn").Value
      DN = ManagementAgent.EscapeDNComponent(RDN).Concat(Container)

      ' If there are no connectors, create the connector, set the distinguished
      ' name attribute, and then add the new connector to the collection.      
      If 0 = Connectors Then
         csentry = ManagementAgent.Connectors.StartNewConnector("user")
         csentry.DN = DN
         csentry.CommitNewConnector()

      ' If a connector exists, get the existing connector and assign the new 
      ' distinguished name value. If the original attribute value is the same
      ' as the new distinguished name, then the original attribute value 
      ' remains the same.
      ElseIf 1 = Connectors Then
         csentry = ManagementAgent.Connectors.ByIndex(0)
         csentry.DN = DN

      ' Throw an exception if more than one connector exists.
      Else
         Dim ExceptionMessage As String
         ExceptionMessage = "Multiple Connectors on 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;           // Management agent connectors
    ReferenceValue DN;            // Distinguished name attribute
    string Container;             // Container name
    string RDN ;                  // Relative distinguished name strings
    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 connectors.
            ManagementAgent = mventry.ConnectedMAs["LDAP-based MA"];
            Connectors = ManagementAgent.Connectors.Count;

            // Construct the distinguished name.
            Container = "CN=users,DC=fabrikam,DC=com";
            RDN = "CN=" + mventry["cn"].Value;
            DN = ManagementAgent.EscapeDNComponent(RDN).Concat(Container);

            // If there are no connectors, create the connector, set the distinguished
            // name attribute, and then add the new connector to the collection.      
            if(0 == Connectors)
            {
                csentry = ManagementAgent.Connectors.StartNewConnector("user");
                csentry.DN = DN;
                csentry.CommitNewConnector();
            }

            // If a connector exists, get the existing connector and assign the new 
            // distinguished name value. If the original attribute value is the same
            // as the new distinguished name, then the original attribute value 
            // remains the same.

            else if(1 == Connectors)
            {
                csentry = ManagementAgent.Connectors.ByIndex[0];
                csentry.DN = DN;
            }

            // Throw an exception if more than one connector exists.

            else
            {
                string ExceptionMessage; 
                ExceptionMessage = "Multiple Connectors on Management Agent";
                throw new UnexpectedDataException(ExceptionMessage);
            }
        }
    }
}

See Also

Reference

StartNewConnector
EscapeDNComponent
DN
CommitNewConnector

Concepts

Provisioning Objects in the Connector Space