Toolbox 2: How to convert schemafiles from OpenLdap to SunOne Directory Server

Okay, you´ve downloaded the Sun One Directory server, want to use an opensource application with schema extensions for OpenLdap… but … the schema files of openldap are non-standard, so you are not able to add them to the Sun One Directory Server. You have to rewrite them. Or convert them with a little script. To be honest, it´s a quick hack … but it worked for me … your milage may vary and perhaps you have to tweak manually. Concatenate the both regular expressions into one line.Usage is ./ [name of the old file]. You will get a S1DS-compatible file. The name of the file is the name of the source-file extended with a .ldif.
#!/usr/local/bin/perl $infile = $ARGV[0]; open(INFILE,"$infile");
open(OUTFILE,">$infile.ldif"); while() {
next if $line =~ /^#/; #Kommentare loeschen
if ($line =~ /^$/) {
} foreach $i (@outfile_pre1) {
if ($i =~ /<--separator-->/) {
$outfile_pre2[$zz2] = $outfile_pre2[$zz2] . $i;
} foreach $i (@outfile_pre2) {
next if $i =~ /^$/;
$i =~ s/\s+/ /gi;
$i =~ s/attributetype /attributeTypes: /gi;
$i =~ s/objectclass /objectClasses: /gi;
$i =~ s/\)$/ X-ORIGIN 'user defined' \)/gi;
$i =~ s/1\.3\.6\.1\.4\.1\.1466\.115\.121\.1\.28/
$i =~ s/1\.3\.6\.1\.4\.1\.1466\.115\.121\.1\.22/
$i =~ s/\) attributeTypes:/\)\nattributeTypes:/gi;
$outfile_pre3[$zz3] = $i;
} @outfile_final=@outfile_pre3; print OUTFILE "dn: cn=schema\n";
foreach $i (@outfile_final) {
print OUTFILE "$i\n";
} close(INFILE);