On 4/10/04 4:00 pm, Marc Chantreux <[EMAIL PROTECTED]>
wrote:

> Chris Ridd wrote:
> 
> 
>> The separator is not optional according to RFC 2849:
>> 
>> ----
>> change-modify            = "modify"             SEP *mod-spec
>> 
>> mod-spec                 = ("add:" / "delete:" / "replace:")
>>                            FILL AttributeDescription SEP
>>                            *attrval-spec
>>                            "-" SEP
>> ----
> 
> thanks for this information.
>> Which version of LDIF.pm are you using? 0.15_01 looks like it prints "-\n"
> 
> i've found 0.15 in my LDIF.pm, do i have to update ? or peraps i don't
> use perl-ldap correctly ?

The only change from 0.15 is that the parameters to open() changed to work
with older perls.

> here is a test :
> 
> use strict;
> use warnings;
> use Net::LDAP::LDIF;
> use Net::LDAP::Entry;
> 
> my $ldif =  Net::LDAP::LDIF->new(
>      \*STDOUT , 'w' , onerror => 'die'
> );

You need to include:

    change => 1

If you want the LDIF file to contain change records instead of "complete"
entries.

> my $e =  Net::LDAP::Entry->new ;
> 
> $e->dn('cn=admin,dc=test');
> $e->add(
>      changetype =>  'modify'
>      , replace => 'sn'
>      , sn => 'toto'
> );

No, that's not right either. Replace those two messages with:

$e->dn('cn=admin,dc=test');
$e->changetype('modify');
$e->replace('sn' => 'toto');


> $ldif->write_entry($e);
> 
> 
> regards

However for me that still only writes:
dn: cn=admin,dc=test
changetype: modify
replace: sn
sn: toto

The RFC I quoted seems to require the trailing "-" lines in the formal
definition of the format but then not use them in the examples, so I'm not
sure if there should be a trailing "-" line. Diffs from 0.15 of LDIF.pm to
give the formally defined behaviour are straightforward:

Index: LDIF.pm
===================================================================
--- LDIF.pm     (revision 432)
+++ LDIF.pm     (working copy)
@@ -9,7 +9,7 @@
 require Net::LDAP::Entry;
 use vars qw($VERSION);
 
-$VERSION = "0.15";
+$VERSION = "0.15_02";
 
 my %mode = qw(w > r < a >>);
 
@@ -120,7 +120,7 @@
 
   if ($url =~ s/^file:(?:\/\/)?//) {
     my $fh = $self->{_attr_fh};
-    unless (open($fh, '<', $url)) {
+    unless (open($fh, '<'.$url)) {
       $self->_error("can't open $line: $!", @ldif);
       return;
     }
@@ -481,7 +481,6 @@
         next;
       }
 
-      my $dash=0;
       foreach my $chg (@changes) {
         unless (ref($chg)) {
           $type = $chg;
@@ -489,11 +488,11 @@
         }
         my $i = 0;
         while ($i < @$chg) {
-         $res &&= print "-\n" if $dash++;
           my $attr = $chg->[$i++];
           my $val = $chg->[$i++];
           $res &&= print $type,": ",$attr,"\n";
           $res &&= _write_attr($attr,$val,$wrap,$lower);
+         $res &&= print "-\n";
         }
       }
     }

However I'm dubious that it is doing the right thing or not :-( Any LDIF
experts around?

Cheers,

Chris


Reply via email to