Mattias Malmgren

2008-02-08
mattias@freefarm.se
This tutorial, including source code files can be downloaded from this zip-file: dip.zip
This document explains the basics of export/import Directory Synchronization Profiles to/from LDIF-files in Oracle Internet Directory version 10g (runing on windows XP).
There is good information on this topic on the internet. How ever, this is a very small example, and there for easy to understand. Also, the information I have found focus on synchronization with another direcotry (e.g. OpenLDAP), rather than LDIF-files using synchronization agents. A synchronization agent is a program you wirte yourself that converts information to/from a custom format that is not supported by the default built-in OID synchronization capabilities.
Links to information on this subject :
Note: This example does not cover bootstrapping, which is the initial process of moving all information from the OID to a connected directory before the incremental synchronization of changes to the DIT begins.
Set up a DIT (Directory Information Tree)
This is a LDIF-file containing the DIT (if you don't understand the syntax, check LDIF Wikipedia):
gm=the top domain for Gambia (a country in Africa, I picked it so it will hopfeully not collide with any other entrys in your OID). Copy and save the DIT into a file called dit.ldif in the directory c:\oidtst (all files should be saved here). Open a command prompt in the same direcotry as you saved the dit.ldif-file in and run the following command ( check out what the parameters mean in the reference. If you have installed your OID on a diffrent port than the default 389, change -p parameter to the port number of your installation. Same thing with the password -w, witch in my case is abc123.):
Using the Oracle Directory Manager Graphical user intercafe (from now on called the GUI) you should now see your new DIT.
Login:
Browse the DIT:
Note: If the GUI don't show anything at all, try to resize the window and make it a little bigger.
Create a synchronization profile
The synchronization profile is made of two files, the map-file and the properties-file. (While it is possible to create a synchronization profile using the GUI, I guess most real world applications will use the command-line approach. )
In the map-file we tell the OID what (and how) changes to the DIT shuld be exported to (in this case) a LDIF-file. The map-file has two parts, the domain rules and the attribute rules. Domain rules tells the OID which part of the DIT shoud be exported and the attribute rules tells the OID what and how attributes should be exporetd. This is my mapping file:
Copy and save this into a file called TestGmExp.map
To better understand the format, see reference and tutorial but basically, this is the format (src=source, dst=destination). Also, there are sample files in the default installation c:\OraHome_1\ldap\odi\samples\ ( C:\OraHome_1=ORACLE_HOME ).
In this simple export example most of the parameters can be omitted in the mapping file, it works anyway. Mappingfiles can e.g. change the name of a field, or add two fields into one. Also in can contain string manipulation so it can truncate fields etc. Se the Oracle documantation on this topic for further information.
Note, if the domainrules is writte like this instead:
DomainRules
dc=gm:NOLDAP
as some documentation suggests, the output in the exported LDIF-file will miss the dn, like this:
Before makeing the properties-file we should find the OID's "last change number". Give this command:
In my case that returns: lastchangenumber=5608. Fill that number in the properties-file on the row odip.profile.lastchgnum.
The properties-file contains information about the synchronization profile:
In the samples directory (c:\OraHome_1\ldap\odi\samples\) you will find files that are commented to tell you what all these properties in the properties-file mean (I also posted this properties-file with comments). But briefly:
Note: if you have Java installed somewhere else, which you problably have, you must change the path C:\\j2sdk1.4.2_16 to that of your installation of Java SDK. You should also put that path + bin in your PATH enviroment variable
This is my agent, written in Java, it simply renames the file and give it a name with a timestamp. After that, it cleans out older files every 10 minutes.
Save this into a file called TestGmExp.java (careful with the name, it is case sensitive even in windowsXP enviroment.
Compile it using the command:
In order to avoid java classpath problems I pack this file in a jar-file along with a manifest-file so it will be an executable jar-file.
Save that into a file called mainClass (note the 2 extra line feeds, file name is case sensitive). Then give this command to create an executable jar-file:
Note: This agent is written in Java, but the agent need not to be a Java-program. It could be a bat-script
or a PERL-program, etc. If you want a PERL-program and are on windows, use the full path to perl.exe
and the PERL-program as an argument, like this for example:
c:\perl\bin\perl.exe c:\agent.pl
Now, upload the profile to the OID with this command:
Note the last parameter -configset 1. There should be a configset in the OID called 1. You can see it in the GUI if you browse to Server Management->Integration Server->Configuration Set 1.
If you click "Refresh" there you should see your profile in the list of profiles. You can also give this command:
Now start the DIP-server using this command:
See oracle documentation on this command, but briefly:
Then give this command
You should be abel to see the change in the GUI (remeber to click refresh) or using a ldap search like this command:
Finaly, check files in the export-file directory, C:\OraHome_1\ldap\odi\data\export You should have a file there called something like TestGmExp_2008_02_06-16_28_05.dat witch contains the change like this:
Click refresh in configurationset 1 in the GUI and you should also be able to see in the status tab of the synchronization profile that the profile executed OK.
I suggest that you, after this, change status of this profile to "DISABLE" under the General-tab.
Error
If you get errors you can look for solutions in the trace-files in C:\OraHome_1\ldap\odi\log. Errors that I have encountered have bean "DATA_NOT_CONSUMED" as a status in the status-tab. That was caused by an error in the Java-program (the agent). Another error have bean NOT_EXECUTED_YET due to failure to start the DIP-server, or started it on wrong port number.
Creating a import synchronization profile is very similar to a export profile. Therefor I will not explain the steps that arepretty much the same as careful as in the export example.
Create a new directory under c:\oidtst called import. Save all your files for this import-example in the new directory c:\oidtst\import
Mapping-file. Save it as TestGmImp.map :
Properties-file. Save it as TestGmImp.properties :
Source code for the agent, save it into a file called TestGmImp.java
Compile the java-program
Create a mainClass file:
Create an executable jar-file
Upload the profile:
Now, evrything seams to work fine. But it is not! When we check the telephonenumber it is not changed by the import-file. Oracle will not tolerate changes to the DIT (directory information tree in case you have forgot the acronym. If you check the log-file C:\OraHome_1\ldap\odi\log\TestGmImp.trc you will see an error message like this:
We have to grant premissions to the agent to make updates to the OID's DIT. This can be done in two ways. Either with an ldif-file using ldapmodify, or with the GUI. The first approach is probably the best. It is documented in the tutorial, in Administrator's Guide and in Administrator's Guide Appendixes. How ever, I don't understand this documentation, so I do it with the GUI. This way I will grant more premissions than I want, but at this point I don't know any other way to do it. If you do, please send an email and tell me how!
Your import agent is now compleat.