> We are using ldap naming (oracle internet directory for name > resolution). > > Is there a command to dump the whole ldap into a tnsnames.ora? > (we need to generate this file automatically with a batch) The following script generates TNS entries each on one single line. It looks like an entire TNS entry on one line still works. If you prefer to make the entries look nicer, some indentations may be necessary (see item 2 of http://yong321.freeshell.org/computer/OracleIdiosyncrasies.html). #!/usr/bin/perl -w #dump_tnsnames.pl: Dump LDAP database connection strings into tnsnames.ora #Usage: dump_tnsnames.pl > tnsnames.ora #Change these parameters $host = "YourOIDHost"; #IP is fine $port = 389; #Normally no need to provide login credential #$user = "cn=orcladmin"; #Doesn't need to be super user #$password = "sesame"; $basedn = "cn=OracleContext,dc=acme,dc=com"; #Could be just "cn=OracleContext". Check with Directory Manager or any ldap browser first. #No need to change below for normal use. use POSIX qw/tmpnam/; $tmpfile = tmpnam; #Make sure the enclosed ldapsearch command works on command line. #qx(ldapsearch -h $host -p $port -D "$user" -w $password -b "$basedn" -s one "cn=*" orclnetdescstring > $tmpfile); qx(ldapsearch -h $host -p $port -b "$basedn" -s one "cn=*" orclnetdescstring > $tmpfile); open TMPFILE, "$tmpfile" or die "Can't open $tmpfile for read: $!\n"; $save = "\n"; while ($line=) { if ($line !~ /^$/ and $save !~ /^$/) { #print $save . $line; $save =~ /^cn=([\w\d]+)/; print "$1 = "; $line =~ /^orclnetdescstring=(.*)/; print "$1\n"; } $save = $line; } close TMPFILE; **************** Outdated **************** Here's a quick and dirty way to generate the tnsnames.ora file. I connect to OID using Softerra Ldap Browser (http://www.softerra.com/products/ldapbrowser.php). Navigate to cn=OracleContext,(dc=youroptionalsubdomain,)dc=yourdomain,dc=com(or edu,gov,etc) Go to Edit or right click the OracleContext node and select LDIF Export to export to a file named OracleContext.ldif. You can choose One Level Only. You can also use one single ldapsearch command to generate this file. Make sure you limit the attribute to orclnetdescstring. Assume your database connection strings are always the same as their service names (if service_name is used): C:\>perl -nle "print \"$2 = $1\" if(/^orclnetdescstring: (.*service_name\s*=\s*([^.)]+).*)/i)" OracleContext.ldif > tnsnames.ora And assume some of your database connection strings are the same as SID names: C:\>perl -nle "print \"$2 = $1\" if(/^orclnetdescstring: (.*SID\s*=\s*([^.)]+).*)/i)" OracleContext.ldif >> tnsnames.ora If you don't have Perl, just put OracleContext.ldif on a UNIX box and run Perl there: perl -nle 'print "$2 = $1" if(/^orclnetdescstring: (.*service_name\s*=\s*([^.)]+).*)/i)' OracleContext.ldif > tnsnames.ora perl -nle 'print "$2 = $1" if(/^orclnetdescstring: (.*SID\s*=\s*([^.)]+).*)/i)' OracleContext.ldif >> tnsnames.ora **************** Not verified ******************** Alternatively, OID has a names server proxy. I think it means you can quickly set up a names server out of your OID installation. If so, launch namesctl and type dump_tnsnames at NAMESCTL> prompt. It would be nice if we could have a dump_tnsnames command running against OID without a names server. Yong Huang