Hi,
There is a bug in Net::LDAP::LDIF when parsing change records.
Refer to RFC 2849, Pages 9 and 10:
---------------------------------------------------------------
# Modify an entry's relative distinguished name
dn: cn=Paul Jensen, ou=Product Development, dc=airius, dc=com
changetype: modrdn
newrdn: cn=Paula Jensen
deleteoldrdn: 1
---------------------------------------------------------------
The changetype attribute is listed in the LDIF before the attribute to
be changed is listed. This is also the way OpenLDAP's ldapmodify tool
parses the LDIF change records.
Net::LDAP::LDIF fails to parse the records properly if the changetype
attribute comes before the attribute to be changed. The result is that
the $entry->attributes() method will return an empty list of attributes.
Net::LDAP::LDIF _should_ parse
---------------------------------------------------------------
dn: cn=foo,o=bar
changetype: modify
add: newAttrib
newAttrib: someValue
---------------------------------------------------------------
however
Net::LDAP::LDIF expects
---------------------------------------------------------------
dn: cn=foo,o=bar
add: newAttrib
changetype: modify
newAttrib: someValue
---------------------------------------------------------------
I wrote a parsing function that can take an LDIF file which has new
records and change records, and call add or modify respectively. It uses
logic like this:
for my $attrib ( $entry->attributes() ) {
if ( $attrib =~ /changetype/ ) {
$record->{entrytype} = "change";
last;
} else {
$record->{entrytype} = "new";
}
}
push @entries, $record;
My parsing of the entrytype fails when the $entry->attributes() list is
empty, unless I modify my LDIF change records to suit Net::LDAP::LDIF.
And then they can't be used with OpenLDAP tools...
Comments?
Thanks!
--
Mike Jackson