All pastes #813623 Raw Edit

Untitled

public text v1 · immutable
·published 2007-12-12 17:48 UTC
rendered paste body
#!/usr/bin/perl

$USAGE          = "Usage: $0 your_ldif_input_file [ldif_output_file]\n";
$input_file     = shift || die $USAGE ;
$output_file      = shift || ’-’;    # write to STDOUT by default

local $/ = "";   # set the record separator to paragraph mode

open(OUTFH, ">$output_file")
      || abort("ERROR: Unable to open $output_file for writing");

open(LDIFFILE, "$input_file")
      || abort("ERROR: Unable to open $input_file for reading ");

  while (defined($_ = <LDIFFILE>)) {
      s/\n //g;                             # unfold the lines
      next unless ( $_ =~ /o=NetscapeRoot\n/);             
# skip unless o=netscaperoot
      next if (s/slapd-//g);            
# skip slapd entries
      s/\nuniquemember: cn=Netscape Directory Server//g;
# rm this unique member
      next if (s/Netscape Directory Server//g);            
# skip Dir Server entries
      s/Server Group/Migrated Server Group/g;              
# change the server group
      print OUTFH "$_" ;             # print to the output file
  }

  close (LDIFFILE);
  close (OUTFH);

undef $/;