[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: slapcat - question.



Frank Swasey writes:
>Today at 11:42am, Andrzej Kwiatkowski wrote:
> 
>> How can i add such ldiff without removing this
>> attributes ??
> 
> slapadd.

Yes.

> If you really want to use ldapadd to create your database, you 
> need to use ldapsearch to dump it.

As long as you don't bump into any timeouts, size limits, or entries
or attributes hidden by access controls.

Otherwise, you could use slapcat, filter out the unwanted attributes
with a small perl script, and then add them with ldapadd:

#!/usr/bin/perl -w
#
# This program filters out OpenLDAP-internal attributes from an LDIF file.
#
# Usage:
#   ldiffilter [<ldif-filename>...]
# Input comes from the filenames on the command line, or from standard input.
# Output goes to standard output.

use strict;

my @skip = qw(structuralObjectClass entryUUID entryCSN
	      creatorsName createTimestamp modifiersName modifyTimestamp);

my $skip_re = join("|", @skip);
my $prev = '';
while (<>) {
    if (/^ /) {
	$prev .= $_;
    } else {
	&out;
	$prev = $_;
    }
}
&out;

sub out {
    (my $tmp = $prev) =~ s/\r?\n //g;
    print $prev unless $tmp =~ /^(?:$skip_re)(?:\;\w+)*:/io;
}

-- 
Hallvard