Hi, is there any way to avoid base64 decoding an attribute value?
I open an existing ldif (300000 users), modify some entries, and print
to standard output the result.
Everything works as expected but the encoded attributes are converted to
plain text.
When I try to import it to the LDAP server I get errors because those
attributes values get interpreted as attributes themselves.
Thx in advance
Joan
ORIGINAL ENTRY
dn: uid=ricardo,ou=people,o=example
objectclass: top
objectclass: person
mailautoreplytext::
WWEgaGUgcmVjaWJpZG8gdHUgbWVuc2FqZS4NClRlIHJlc3BvbmRlcsOpI
HBlcnNvbmFsbWVudGUgbG8gYW50ZXMgcG9zaWJsZS4NClVuIHNhbHVkbzogUmljYXJkbw==
mailautoreplytext;lang-es: $
MODIFIED ENTRY
dn: uid=ricardo,ou=people,o=example
objectclass: top
objectclass: person
mailautoreplytext: Ya he recibido tu mensaje.^M
Te responderé personalmente lo antes posible.^M
Un saludo: Ricardo
mailautoreplytext;lang-es: $
If I add:
$v =~ s/\n/\n /g;
before printing printing the value I can "fix" this entry but I'd rather
keep the original encoding.
CODE SNIP
my $ldifmig = Net::LDAP::LDIF->new( $ldif_a_migrar, "r", onerror =>
'undef' );
while( not $ldifmig->eof() ) {
my $entry = $ldifmig->read_entry();
if ( $ldifmig->error() ) {
print "Error msg: ",$ldifmig->error(),"\n";
print "Error lines:\n",$ldifmig->error_lines(),"\n";
}
else {
my $dn = $entry->dn();
if ( $entry->exists('mail') ) {
$entry->add ( 'objectclass' => [
'inetadmin',
'inetlocalmailrecipient',
'ipuser'
]);
}
my @attributes = $entry->attributes;
print "dn: $dn\n";
for my $attribute (@attributes) {
my $values = $entry->get_value($attribute , asref => 1);
for my $v (@{$values}) {
#Workaround
#$v =~ s/\n/\n /g;
print "$attribute: $v\n";
}
}
print "\n";
}
}
$ldifmig->done();