Changing Oracle Internet Directory for Fedora Directory Server for oracle net names resolution, part 2: export and import connectstrings and configuring the clients

Before we can import any connectstrings to a place the clients are able to use, we need to setup an ‘OracleContext’. The can easily be done with the directory server manager of the Fedora Directory Server:
Goto the ‘directory’ tab in the directory server manager and add a common name (cn) with objectclass ‘orclContext’. This will be the place where the connectstring-objects will be imported. Write the distinguised name (full name of the object) down. In my case, it is ‘cn=OracleContext, dc=oracle, o=gsd.com”

For most things I do with LDAP servers, I feel comftable with LDAP Browser/Editor. (It uses java).

First, we have to export the connectstrings out of the OID. Using the LDAP browser, I can make selections of what I want to export. This is quite handy, because I just want to export the oracle connectstrings (and their child objects) , and not all the other stuff oracle puts in its OID. (like database security objects, DAS objects, Portal objects, etc.). Search for the first connectstring in the OracleContext of the OID, press shift (in the case of the LDAP browser), and select all the connectstrings. Next, choose ‘LDIF’, export and type the name of the export/ldif file. Also select ‘all children’.

The previous action has given us an ldif file of all the connectstrings in the OID. (ldif=Ldap Directory Interchange Format).

In my case, I wanted to change the position of the Oracle Context. If you keep the Oracle Context the same, skip this part. LDIF files have some properties which make text manipulation annoying, the maximum row length of a LDIF file is 77 characters, and if a row is a continuation of a previous row if it starts with a space. With only a few connectstrings, this can easy be adjusted, but in my case I wanted to transfer 366 connectstrings. If you need to do the same, here is what I have done:
Alter the location (only works if the “old” cn is not ‘scattered’ at the end of the line, of course)


frits@bedrock:~/ldap$ cat export_from_oid.ldif | sed 's/dc=cmg/dc=oracle, o=gsd.com/' | fold -w 77 > name_changed.ldif

Problem here is that my new entry is longer than the old one. This could (and did) result in too long lines at some places. The ‘fold’ utility does break the line at the 77th position, but does NOT place a space on the next line. I could write a little script to do so, but thought it would be faster to alter these by hand. The next statements will check if the all the lines are valid, and will show the invalid lines (which then can be easily corrected in vi):


frits@bedrock:~/ldap$ cat name_changed.ldif | egrep -v '\w:' | egrep -v '^$' | egrep -v '^\ .*'

Next step is to import the ldif file into our Fedora Directory Server:


frits@bedrock:~/ldap$ ldapadd -x -c -D "cn=Directory Manager" -w -h ldaphost

Apparently, it seems we have to import at least twice, to get all the children which belong to the directory objects imported. (I’ve checked it by going to the last connectstring (the order in LDAP browser is the same as the order in the ldif file) and expanded it, and see if we got ‘cn=’,’cn=DESCRIPTION_0′,’cn=ADDRESS_LIST_0′ and ‘cn=ADDRESS_0’). My guess is this is because the hierarchical order is not always obeyed in the ldif file (which could result to a non-existent parent for an object, which means it is not imported).

Now we have the connectstrings imported, we must configure the clients to use it. There are two files responsible for letting a client use ldap:

SQLNET.ORA
This file sets the names-resolution method used. This is my line:

NAMES.DIRECTORY_PATH=(LDAP,TNSNAMES)

LDAP.ORA
This file sets the ldap properties. This is the content of my ldap.ora:

DEFAULT_ADMIN_CONTEXT = "dc=oracle, o=gsd.com"
DIRECTORY_SERVERS = (ldapserver:389:636)
DIRECTORY_SERVER_TYPE = OID

Next, try ‘tnsping’ with a connectstring, and see how charming!

Advertisements
3 comments
  1. Remigiusz Boguszewicz said:

    Great article. Thank You. I just implemented the openldap as the source for resolving oracle services – a replacement for tnsnames – and it feels great.

  2. Mark Coffin said:

    Hi Frits,

    Sorry, I’m a little new to ldap and I’m having a little bit of trouble.

    I’m following your guide and I’m at the part:

    Goto the ‘directory’ tab in the directory server manager ….

    I log into server the console and open Directory Server, then click on the the Directory tab. I’m not sure how/where to create the common name with objectclass ‘orclContext’.

    I see a tree with the mahinename with the following nodes NetscapeRoot,admassist,monitor,config.

    Any help would be greatly appreciated. I would like to eventually replace our existing ONames server.

    Thank you.

  3. Shehzad said:

    Hi!,
    a gr8 article i must say. I am a stuck at the exporting connectstrings part…

    Plz can u elaborate as to what specifically should I be looking in the OracleContext of OID to export….

    waiting for a favorable reply…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: