9 Synchronizing with Relational Database Tables

This chapter explains how to synchronize data from tables in a relational database with Oracle Internet Directory. The synchronization can be either incremental—for example, one database table row at a time—or all the database tables at once.


Multi-valued attribute synchronization from database to Oracle Internet Directory is not supported.

The process of synchronization with a database involves executing a directory integration profile and includes the following steps:

  1. Retrieving the data from the database. This involves executing a SQL SELECT statement that retrieves the specified data records from the database.

  2. Writing the data into the directory. This involves converting the retrieved data records to LDAP attribute values and performing the LDAP operation on the directory.


Before reading this chapter, be sure to familiarize yourself with the introductory chapters about Oracle Directory Integration Platform—specifically:

Oracle Internet Directory 11g Release 1 (11.1.1) does not support exporting data from Oracle Internet Directory to a relational database.

This chapter contains these topics:

Preparing the Additional Configuration Information File

During synchronization from a relational database to Oracle Internet Directory, the additional configuration information file governs the retrieval of data from the database. It provides the Oracle Directory Integration Platform with the following information:

  • The SELECT statement to execute

  • Either the attributes or the database columns to be used in incremental synchronization. Generally, this is either an attribute that contains a timestamp or a change sequence number that the next SQL statement should use to retrieve incremental data.

To configure this file, use the sample file DBReader.cfg.master in the $ORACLE_HOME/ldap/odi/conf directory, and edit it to your specifications.

Formatting the Additional Configuration Information File

It is very important to follow the correct format of this file. The various sections are divided using TAG names. Every TAG section has a list of parameters and their respective values. The general layout is as follows:


PARAMETER2: value\
VALUE continuation\
value continuation\
end of value continuation

PARAMETER2: value\
end of value continuation

For example, following this format, the DBReader.cfg.master file looks like this:

EMPNO EmpNum,\


Note that the entire SELECT statement is put as a value in the SELECT parameter in the section represented by the tag DBQUERY. Because it is a lengthy value, the value continuation character is put as the last character in every line until the SELECT statement ends.

The CHANGEKEYATTRS parameter value is the name of the columns to be used while performing incremental synchronization. The values of these columns are always stored in the orclodipcondirlastappliedchgnum attribute of the profile. Every time the SELECT statement is executed, the current values of this attribute are put into the SQL statement accordingly. This ensures that the data is always retrieved incrementally.

If there are multiple column names in the CHANGEKEYATTRS—for example, column1:column2—then the value in the orclodipcondirlastappliedchgnum attribute of the profile is stored as value1~value2 and so on, with value1 corresponding to column1 and value2 to column2.

Column names are retrieved into Oracle Directory Integration Platform as attribute value pairs and subsequently mapped into LDAP attribute values according to set mapping rules. For this reason, all columns names retrieved in the SELECT statement must be simple names rather than expressions. For example, you can have the expression REPLACE(EMAIL),'@ACME.COM',''), but it retrieves the expression value as UID.

In this example, the Modified_Date is the key for incremental synchronization. Because it is a date, it must be presented in string format.

When the profile is created, the orclodipcondirlastappliedchgnum attribute must be set to some value. All changes after this date—that is, rows in the table with LAST_UPDATE_DATE greater than this value—are retrieved. For example, if the orclodipcondirlastappliedchgnum attribute is set to 20000101000000, then all employee changes since January 1, 2000 are retrieved.

Because of the ORDER BY clause, all the database rows returned are in the order of LAST_UPDATE_DATE—that is, the changes retrieved and applied to the directory are in chronological order. Once the last change is retrieved and applied:

  1. The orclodipcondirlastappliedchgnum attribute value is set to the Modified_Date from the last row retrieved.

  2. The profile is updated.

Whenever the Oracle Directory Integration Platform executes the profile again, it uses the previously stored value.

Preparing the Mapping File

To configure the mapping rules, follow the instructions in "Mapping rules and formats".

Preparing the Directory Integration Profile

You can create the directory integration profile by using the Oracle Enterprise Manager Fusion Middleware Control. When you use Oracle Enterprise Manager Fusion Middleware Control, you must upload the additional configuration information file and the mapping file by using the update operation of the manageSyncProfiles command.

To configure the directory integration profile, follow the general instructions in "Registering Connectors in Oracle Directory Integration Platform", but with these specific instructions in mind:

  • Do not set a value for the agent execution command (orclodipAgentExeCommand) attribute.

  • Set the interface type (orclodipDataInterfaceType) attribute to DB.

Example: Synchronizing a Relational Database Table to Oracle Internet Directory

This section demonstrates how to synchronize a relational database table with Oracle Internet Directory. It contains these topics:

In this example, the following relational database table containing employee data is synchronized with Oracle Internet Directory:

98357 JOHN DOE 2-JAN-2000 JOHN.DOE@ACME.COM 435-324-3455
98360 ROGER BECK 3-JUL-2001 ROGER.BECK@ACME.COM 435-324-3600
98365 JIMMY WONG 4-MAR-2001 JIMMY.WONG@ACME.COM 435-324-2390

You can find a sample profile (DBReader.properties), configuration, and mapping files for this example in the $ORACLE_HOME/ldap/odi/conf directory. In this example:

  • The name of the table is Employee

  • The Profile Name is TESTDBIMPORT.

  • The employee number (EMPNO) is used to join a database record with a directory entry. It is specified in the OID Matching Filter (orclOdipOIDMatchingFilter) attribute described in the attributes reference chapter of the Oracle Identity Management User Reference.

  • This table is present in the testsync/testsyncpwd schema in a database. The database is located on the host machine.acme.com, the database listener port is 1526, and the SID is iasdb. The database URL is machine.acme.com:1526:iasdb.

  • Appropriate read/write permissions were given explicitly to this profile, namely, orclodipagentname=testdbimport, cn=subscriber profile, cn=changelog subscriber, cn=oracle internet directory

  • The profile is created in configuration set 1.

Configuring the Additional Configuration Information File

This example uses the same Additional Configuration Information file described earlier in "Preparing the Additional Configuration Information File".

Configuring the Mapping File

The mapping file for this example contains the following:

ename: : : :cn: :person
ename : : : :sn: :person
uid : : : :uid: :inetOrgperson:
EMail: : : :mail: :inetOrgperson
Telephone: : : :telephonenumber: :inetOrgperson
empnum: : : :employeenumber: :inetOrgperson

This mapping file specifies the following:

  • Directory entries are created as uid=%,dc=testdbsync,dc=com. The percent sign (%) is a placeholder for the actual value of uid. The uid must be present in the mapping rules so that it has a value after the mapping. Otherwise, the DN construction fails.

  • Both the cn and sn attributes need to have the same value as ename.

  • The uid element must have the value of the EMail prefix, which is the element of the e-mail address prior to the at sign (@) character.

  • The empnum attribute becomes employeenumber in the directory entry.

  • The telephone attributes becomes telephone number in the directory entry.

Configuring the Directory Integration Profile

The directory integration profile for this example contains the attribute values as described in Table 9-1. A sample integration profile with these values populated and the corresponding mapping and configuration files are available in $ORACLE_HOME/ldap/odi/conf directory. You can create the profile by using Oracle Enterprise Manager Fusion Middleware Control or following the instructions described in "Creating Synchronization Profiles".

Table 9-1 Directory Integration Profile for TESTDBIMPORT

Attribute Value

Profile Name (odip.profile.name)


Synchronization Mode (odip.profile.syncmode)


Profile Status (odip.profile.status)


Agent Execution Command (odip.profile.agentexecommand)


Advanced Configuration Information (odip.profile.configfile)

Maintains configuration details which are not individually maintained in LDAP attributes.

Connected Directory Account (odip.profile.condiraccount)


Connected Directory Account Password (odip.profile.condirpassword)


Connected Directory URL (odip.profile.condirurl)


Interface Type (odip.profile.interface)


Mapping File (odip.profile.mapfile)

Attribute for storing mapping rules.

OID Matching Filter (odip.profile.oidfilter)


This means that employeenumber is used to search the directory while looking for a match. If a match is found, then the directory entry is modified. Otherwise, a new entry is created. This is necessary to ensure that the orclOdipOIDMatchingFilter attribute is unique in the database also.

Once a database row is retrieved, the Oracle Directory Integration Platform searches the directory for that employeenumber in the domain dc=testdbsync,dc=com according to the domain rules. If it gets a match, it updates that entry with the latest values of the columns in the row retrieved. If it does not get a match, it creates a new entry in the directory with all the attributes from the column values.

Last Applied Change Number (odip.profile.lastchgnum)


This means that the first time the profile executes, it retrieves and synchronizes all four rows. Subsequently, it retrieves rows only when the LAST_UPDATE_DATE column in the table is updated to the time last modified.

Uploading the Additional Configuration Information and Mapping Files

Use the update operation of the manageSyncProfiles command to update the additional configuration information and mapping files, as follows:

manageSyncProfiles update -h HOST -p PORT -D WLS_USER -pf PROFILE_NAME -file FILE_NAME

Synchronization Process

In this example, the sequence of steps in the synchronization process is:

  1. The Oracle Directory Integration Platform starts a new profile thread for the TESTDBIMPORT profile every time the value specified in the scheduling interval (odip.profile.schedinterval) attribute expires.

  2. The profile thread reads the additional configuration information to get the SQL to execute, and then runs the SQL.

  3. For every row retrieved from the database, the mapping rules are applied to the record, and LDAP attributes are created.

  4. Depending on the OID Matching Filter (odip.profile.oidfilter) attribute, the Oracle Directory Integration Platform determines whether a matching entry exists in Oracle Internet Directory. If it exists, then it is updated. If not, then a new entry is created. After the directory operation, the last applied change number (odip.profile.lastchgnum) attribute is updated.

Observations About the Example

When a row is retrieved from the database, it is in the following form:

EmpNum: 98357
TELEPHONE: 435-324-3455
Modified_Date: 20000102000000

After the mapping is performed on this record, the output is in the following form:

dn: uid=john.doe,dc=testdbsync,dc=com
employeenumber: 98357
telephonenumber: 435-324-3455
objectclass: person
objectclass: inetorgperson

A subtree search is made in the directory with the filter employeenumber=98357 under the domain dc=testdbsync,dc=com. If the search yields an existing entry, then that entry is updated. Otherwise, a new entry is created. Because the OID Matching Filter (odip.profile.oidfilter) attribute is set to employeenumber, every database record retrieved must have that column. In this case, it is EmpNum as it maps to employeenumber.

Any other attributes in the mapping file that are not in the data retrieved by SQL are ignored—for example, the birthday attribute.

After the profile thread processes all the change records from SQL, it updates the directory with correct values for these attributes:

  • Last Applied Change Number (odip.profile.lastchgnum)

  • Last Execution Time (orclOdipLastExecutionTime)

  • Last Successful Execution Time (orclOdipLastSuccessfulExecutionTime)