OpenSourceSoftware

Openldap-2.0.27 to Symas-Ldap-2.3.21

service ldap stop
slapcat > /tmp/openldap.ldif
mv /var/lib/ldap/* /var/lib/ldap.old/

cp /opt/symas/etc/openldap/DB_CONFIG.default /var/lib/ldap/DB_CONFIG
# ldiffix.pl /tmp/openldap.ldif /tmp/symasldap.ldif
sudo -u ldap slapadd -l /tmp/symasldap.ldif
# messages like “SIOCSIFFLAGS: Cannot assign requested address” are harmless
service cdsserver start

ldiffix.pl

#!/usr/bin/perl -w
use strict;
use Net::LDAP::LDIF;

if ($#ARGV != 1) {
die “Usage: $0 n”;
}

my ($count, $err) = (0, 0);
my ($infile, $outfile) = @ARGV;

my $ldif = Net::LDAP::LDIF->new($infile, “r”, onerror => ‘undef’)
or die “Can’t open $infile for readingn”;
my $out = Net::LDAP::LDIF->new($outfile, “w”, onerror => ‘undef’)
or die “Can’t open $outfile for writingn”;

while (not $ldif->eof()) {
my $entry = $ldif->read_entry();
$count++;
if ($ldif->error()) {
print “Error msg: “, $ldif->error(), “n”;
print “Error lines:n”, $ldif->error_lines(), “n”;
$err++;
next;
}
next unless $entry;
$entry->dn() =~ /^([^=]+)=([^,]+)/ or die “Bad DN: “, $entry->dn(), “n”;
my ($attr, $value) = ($1, $2);
if ($entry->get_value($attr) ne $value) {
print $entry->dn(), “: $attr != $value, fixingn”;
$entry->replace($attr => $value);
$err++;
}
$out->write_entry($entry);
}

print “$infile: $count objects, $err errorsn”;

Advertisements
Standard

One thought on “Openldap-2.0.27 to Symas-Ldap-2.3.21

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