I have a use case for analyzing LDIF dumps of our LDAP directory. The dump utility puts some controls in the output file, so Net::LDAP::LDIF won't read them, it fails with "Controls only allowed with LDIF change entries".
I put a patch on to allow reading of controls for non-change entries by specifying controls_always_legal => 1 on the Net::LDAP::LDIF->new() call. Can we consider including this patch (possibly modified if people see fit) in the next release? --- LDIF.pm~ 2013-05-07 09:07:19.000000000 -0400 +++ LDIF.pm 2013-05-07 08:45:34.000000000 -0400 @@ -15,7 +15,7 @@ if (CHECK_UTF8); } -our $VERSION = '0.20'; +our $VERSION = '0.21'; # allow the letters r,w,a as well as the well-known operators as modes my %mode = qw(r < < < w > > > a >> >> >>); @@ -66,6 +66,7 @@ changetype => 'modify', modify => 'add', wrap => 78, + controls_always_legal => 0, %opt, fh => $fh, file => "$file", @@ -352,7 +353,7 @@ my $attr; my $xattr; - if (@controls) { + if (@controls && !$self->{controls_always_legal}) { $self->_error("Controls only allowed with LDIF change entries", @ldif); return; } --- LDIF.pod~ 2013-05-07 09:07:40.000000000 -0400 +++ LDIF.pod 2013-05-07 08:48:52.000000000 -0400 @@ -135,6 +135,11 @@ Example: raw =E<gt> qr/(?i:^jpegPhoto|;binary)/ +=item controls_always_legal =E<gt> 1 + +Always allow controls in LDIF input, even if the input LDIF entry is not +a change entry. + =back =back