Fwd: Net::LDAP::LDIF patches

--Boundary-00=_otSJAJuvrLECuNe
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi all,

I beg your pardon for re-posting this message I sent last week (Maybe it got 
lost in the aftermath of the MyDoom outbreak).

IMHO the patch attached fixes a quite important case in parsing LDIF files,
so that I ask for inclusion into the perl-ldap CVS.

Please give me feedback what you think of it.

Peter

----------  Forwarded Message  ----------

Subject: Net::LDAP::LDIF patches
Date: Sunday 01 February 2004 14:40
From: Peter Marschall <peter@adpm.de>
To: perl-ldap@perl.org

Hi Graham, hi Chris, hi list,

plaiying a bit with Net::LDAP::LDIF I found that Net::LDAP::LDIF
does not cope with LDIF files of the form

------------ >8 snip 8< ------------
# comment

#comment
dn: cn=x
.....
------------ >8 snip 8< ------------

That is with LDIF files that have 2 or more comments separated by
blank lines.

The attached patch fixes this problem.

In addition to that it forbids empty entries when not at the nd of the file
and comments out a statement that ignores the first line of an entry if
the lines contains nothing but digits.

Maybe this statement is a remnant from pre LDIF v1 versions of
Net::LDAP::LDIF, but to me it seems strange to simply slurp away those lines
from each entry without telling the user that this may possibly be an error.

Peter
--
Peter Marschall
eMail: peter@adpm.de

-------------------------------------------------------



-- 
Peter Marschall
eMail: peter@adpm.de

--Boundary-00=_otSJAJuvrLECuNe
Content-Type: text/x-diff;
  charset="us-ascii";
  name="perl-ldap-0.31-LDIFcomment.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="perl-ldap-0.31-LDIFcomment.patch"

# patch to allow comments separated by blank lines in LDIF files
--- lib/Net/LDAP/LDIF.pm
+++ lib/Net/LDAP/LDIF.pm	2004-01-28 09:37:32.000000000 +0100
@@ -76,17 +76,20 @@
   {
     local $/ = "";
     my $fh = $self->{'fh'};
-    my $ln = $self->{_next_lines} || scalar <$fh>;
-    unless ($ln) {
-       $self->{_next_lines} = '';
-       $self->{_current_lines} = '';
-       $self->eof(1);
-       return;
-    }
-    $ln =~ s/\n //sg;
-    $ln =~ s/^#.*\n//mg;
-    chomp($ln);
-    $self->{_current_lines} = $ln;
+    my $ln;
+    do {	# allow comments separated by blank lines
+      $ln = $self->{_next_lines} || scalar <$fh>;
+      unless ($ln) {
+         $self->{_next_lines} = '';
+         $self->{_current_lines} = '';
+         $self->eof(1);
+         return;
+      }
+      $ln =~ s/\n //sg;
+      $ln =~ s/^#.*\n//mg;
+      chomp($ln);
+      $self->{_current_lines} = $ln;
+    } until ($self->{_current_lines} || $self->eof());
     chomp(@ldif = split(/^/, $ln));
     do {
       $ln = scalar <$fh> || '';
@@ -112,8 +115,13 @@
   $self->_clear_error();
   
   @ldif = $self->_read_lines;
-  return unless @ldif;
-  shift @ldif if @ldif && $ldif[0] !~ /\D/;
+
+  unless (@ldif) {	# empty records are errors if not at eof
+    $self->_error("illegal empty LDIF entry")  if (!$self->eof());
+    return;
+  }
+  # What does that mean ???
+  #shift @ldif if @ldif && $ldif[0] !~ /\D/;
 
   if (@ldif and $ldif[0] =~ /^version:\s+(\d+)/) {
     $self->{version} = $1;

--Boundary-00=_otSJAJuvrLECuNe--

0
peter5 (37)
2/7/2004 6:16:08 PM
perl.ldap 1268 articles. 0 followers. Follow

2 Replies
617 Views

Similar Articles

[PageSpeed] 36
Get it on Google Play
Get it on Apple App Store

On 7/2/04 6:16 pm, Peter Marschall <peter@adpm.de> wrote:

> Hi all,
> 
> I beg your pardon for re-posting this message I sent last week (Maybe it got
> lost in the aftermath of the MyDoom outbreak).
> 
> IMHO the patch attached fixes a quite important case in parsing LDIF files,
> so that I ask for inclusion into the perl-ldap CVS.
> 
> Please give me feedback what you think of it.
> 
> Peter

I've just committed both of your patches. Sorry about the delay.

My initial thought on the LDIF bug was that there are some ambiguities in
the LDIF definition with respect to comments. I don't exactly recall what
though :-(

I can't imagine what the code ignoring lines just containing digits was
doing :-)

Cheers,

Chris

0
chrisridd
2/7/2004 6:50:50 PM
Hi Chris,

I appreciate your support a lot.

Thank you very much
Peter

-- 
Peter Marschall
eMail: peter@adpm.de

0
peter
2/7/2004 7:12:54 PM
Reply:

Similar Artilces:

[Fwd: make Net::LDAP::LDIF more similar to Net::LDAP]
--------------95D5815B06BDC2BD1A0ABFEB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --------------95D5815B06BDC2BD1A0ABFEB Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mozilla-Status2: 00000000 Message-ID: <40C7B13E.8864E5A0@cs.adelaide.edu.au> Date: Thu, 10 Jun 2004 10:54:22 +1000 From: Sion Camilleri <sion@cs.adelaide.edu.au> Reply-To: sion@cs.adelaide.edu.au X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 To: Graham Barr <gbarr@pobox.com>...

make Net::LDAP::LDIF more similar to Net::LDAP
Hi Graham, hi Chris, hi list, I would like to rework Net::LDAP::LDIF a bit so that its API resembles that of Net::LDAP a bit more while still keeping the traditional API. The reason for this is that in application I often need to distinguish between Net::LDAP and Net::LDAP::LDIF because some methods are only implemented on one side. I\'d like to start with a code() method that tries to mimic the Net::LDAP one and I\'d like to extend the Net::LDAP::Entry->update() method so that it takes a Net::LDAP::LDIF object as an argument. The latter one requires a...

Net::LDAP and Net:LDAP::LDIF read & add problems
I'm trying to read in a simple LDIF file to add an entry to my LDAP server. Here is the basic routine (extraneous details omitted for brevity and security): $ldif = Net::LDAP::LDIF->new($tmp,"r",onerror => 'warn'); $entry = $ldif->ready_entry(); $ldap = Net::LDAP->new($LDAPSERVER); $result=$ldap->bind("$binddn",password=>"$bindpass",version=>"3"); $result=$ldap->add($entry); Now, everything seems to work until I get to the $ldap->add method. From that I get various versions of the following: object...

Fw: Re: make Net::LDAP::LDIF more similar to Net::LDAP
Am 08.06.2004 um 18:29 Uhr haben Sie geschrieben: > On 8 Jun 2004, at 16:56, peter@adpm.de wrote: > > I\'d like to start with a code() method that tries to mimic the >> Net::LDAP one and >I assume you mean better error handling ? My first goal is having a code() method in Net::LDAP::LDIF. > > I\'d like to extend the > > Net::LDAP::Entry->update() method so that it takes a > > Net::LDAP::LDIF object as an argument. The latter one > > requires a bit of work in Net::LDAP::LDIF to make it > > correct. > Not su...

Fw: Re: make Net::LDAP::LDIF more similar to Net::LDAP #2
Hi, Am 09.06.2004 um 01:44 Uhr haben Sie geschrieben: > Extending Net::LDAP::Entry to update against LDIF and LDAP objects > could allow the changetype modifications to be to produced. > > This would be really useful to produce changetypes for entry objects by > updating against an LDIF object to produce the changetype LDIF required > up to synchronise entry objects. as Graham posted you can to that already now. Simply create your Net::LDAP::Entry object with the changes option set to TRUE. Having created the ::LDIF object that way you autom...

Net::LDAP and Net:LDAP::LDIF read & add problems #2
I'm trying to read in a simple LDIF file to add an entry to my LDAP server. Here is the basic routine (extraneous details omitted for brevity and security): $ldif = Net::LDAP::LDIF->new($tmp,"r",onerror => 'warn'); $entry = $ldif->ready_entry(); $ldap = Net::LDAP->new($LDAPSERVER); $result=$ldap->bind("$binddn",password=>"$bindpass",version=>"3"); $result=$ldap->add($entry); Now, everything seems to work until I get to the $ldap->add method. From that I get various versions of the following: obj...

Net::LDAP::LDIF patches
--Boundary-00=_mHQHAtKg5XSoN6D Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi Graham, hi Chris, hi list, plaiying a bit with Net::LDAP::LDIF I found that Net::LDAP::LDIF does not cope with LDIF files of the form ------------ >8 snip 8< ------------ # comment #comment dn: cn=x ..... ------------ >8 snip 8< ------------ That is with LDIF files that have 2 or more comments separated by blank lines. The attached patch fixes this problem. In addition to that it forbids empty entries ...

Net::LDAP::LDIF patch
--Boundary_(ID_eVX2/r0+olpKHjpGQ9WN0A) Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT Hi! I'm using LDIF for client-server communication.. The server is accessing LDAP server, and returns the results to the requesting client.. (You maybe ask 'WHY?', but it's only a minor part of the application) This reply message is in LDIF.. When client requests only DN for fetched attributes, an entry-set containing only DNs is returned to client, which tries to make Net::LDAP::Entry objects from them.. The problem is, that curre...

Fwd: Re: Some feedback on Net::LDAP::LDIF...
--Boundary-00=_MkL5CQMvq7ZG1zn Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, since I did not get any feedback about the patch for D. Wood's issue of opening Windows-created LDIFs in Linux/Unix I am re-sending the patch. Please test and give me feedback ! Thanks in advance Peter ---------- Forwarded Message ---------- Subject: Re: Some feedback on Net::LDAP::LDIF... Date: Monday 27 June 2005 13:48 From: Peter Marschall <peter@adpm.de> To: perl-ldap@perl.org Cc: "Chris Ridd...

[Fwd: Net::LDAP::LDIF RFC non compliance (I think)]
---------------------------- Original Message ---------------------------- Subject: Net::LDAP::LDIF RFC non compliance (I think) From: "Erik Ableson" <eableson@mac.com> Date: Thu, January 27, 2005 6:44 am To: gbarr@pobox.com -------------------------------------------------------------------------- Greetings, I'm having some problems with the (otherwise excellent) ldifdiff.pl script output. I'm importing data into a (shudder) MIIS system and they seem to have interpreted the RFC 2849 slightly differently than ldifdiff.pl. They appear to be wor...

Net::LDAP::LDIF should support LDIF comments
Hi, comments are an official part of LDIF, but the Perl module doesn't support them right now. RFC 2849 (LDAP Data Interchange Format) says on page 6: 3) Any line that begins with a pound-sign ("#", ASCII 35) is a comment line, and MUST be ignored when parsing an LDIF file. Why do I need that? I wrote an LDIF import utility that writes all entries that had an error into an LDIF output file for manual (or automatic) review. However it would be great to add the LDAP server's error messages as a comment in from of every entry. Code snipplet: .... ...

Net::LDAP v0.28, bug in Net::LDAP::Constant, :all not supported
Net::LDAP::Constant no longer supports the :all tag in the export list due to the switch from Exporter to a manual export routine. So, while the following: perl -MNet::LDAP::Constant=:all -e 1 worked fine in 0.2701, it now dies with the error: ":all" is not exported by the Net::LDAP::Constant module at -e line 0 Can't continue after import errors at -e line 0 BEGIN failed--compilation aborted, <DATA> line 197. The documentation for Net::LDAP::Constant still documents the ':all' tag. I am not subscribed to the list, so if some...

Fwd: Net::LDAPS
Begin forwarded message: > From: "jsingh" <jsingh@fdu.edu> > Date: Tue Jul 15, 2003 14:20:48 US/Pacific > To: <gbarr@pobox.com> > Subject: Net::LDAPS > Reply-To: <jsingh@fdu.edu> > > Sir > > =A0I am unable to use Net::LDAPS to connect to the SSL port of=A0 my = LDAP=20 > server, I keep getting the error =A0=93IO::Socket::SSL: Timeout=A0=A0=A0= =A0=A0=A0=A0=20 > ...propagated at testldaps.pl=94. Could you please tell me what I am=20= > doing wrong. I am using Solaris 8 box with perl 5.8 and the package is=20=...

Fwd: net::ldap
Begin forwarded message: > From: Takis Skagos <takis.skagos@sasktel.sk.ca> > Date: 10 February 2004 16:43:25 GMT > To: gbarr@pobox.com > Subject: net::ldap > Message-Id: <40290A2D.6020502@sasktel.sk.ca> > > Hi, > > I've just downloaded your really nice net::ldap perl-ldap module. > It is much nicer than the perldap stuff I've been using for the past > while. However, I have a question regarding one of the sample > programs I saw on the CPAN site. > > In the sample program you are using a method called "a...

Web resources about - Fwd: Net::LDAP::LDIF patches - perl.ldap

Resources last updated: 1/7/2016 7:11:19 PM