Subject: | Net::LDAP::Entry::delete/replace misbehaving? |
In Net::LDAP::Entry, it appears that either the delete and replace functions are misbehaving or
the new and add functions is misbehaving. If you create a new object and specify an attribute
with an empty array as it's values, the object contains a has a a hash entry for the attribute that
points to and empty array:
$ perl -MNet::LDAP::Entry -e 'my $e = Net::LDAP::Entry->new( "dc=com", foo => [] ); print $e-
Show quoted text
>dump;'
------------------------------------------------------------------------
dn:dc=com
foo:
The same occurs if you 'add' an attribute with an empty array as it's value:
$ perl -MNet::LDAP::Entry -e 'my $e = Net::LDAP::Entry->new; $e->add( foo => [] ); print $e-
Show quoted text>dump;'
------------------------------------------------------------------------
foo:
However, if your entry contains an attribute, and you delete the final value of the attribute, the
object no longer contains any reference to the attribute at all:
$ perl -MNet::LDAP::Entry -e 'my $e = Net::LDAP::Entry->new( "dc=com", foo => [ 1 ] ); $e-
Show quoted text>delete( foo => 1 ); prinnt $e->dump;'
------------------------------------------------------------------------
dn:dc=com
And the same occurs if you replace an existing attribute with an empty array:
perl -MNet::LDAP::Entry -e 'my $e = Net::LDAP::Entry->new( "dc=com", foo => [ 1 ] ); $e-
Show quoted text>replace( foo => [] ); print $e->dump;'
------------------------------------------------------------------------
dn:dc=com
This behavior is problematic if you load and entry, make changes to it (such as deleting the
final value), and the do an update on the entry. Because the attribute is no longer associated
with the object, the atribute is not modified on the server. The workaround I am currently
using is to follow every 'delete' and 'replace' on an attribute with an 'add' that specifies an
empty array as a value.
If this is in fact the intended behavior, then it would be nice if it was clarified in the
documentation.
Thanks!