grinder has asked for the wisdom of the Perl Monks concerning the following question:

Monks, I might be doing this wrong, but the documentaion is a bit scanty on the subject. I'm trying to use Net::LDAP to modify a person: changing their DN to reflect the change in their OU.

sub change { my $master = shift; my $entry = shift; my $dn = $entry->dn(); (my $new = $dn) =~ s/\bou=Engineering\b/ou=Research/; my $err = $master->moddn( $entry, newrdn => $new ); warn "could not update $dn: ", $err->text, ' (err=', $err->code, +")\n" if $err->code > 0; $err->code > 0 ? 0 : 1; }

I am aware that the old DN will still exist afterwards, there an attribute that can be passed to clean that up, but one thing at a time...

I get the following error on the $master->moddn call:

Can't locate object method "text" via package "Net::LDAP::ModDN"

Short of diving into the code, I don't know what's going on. (There's no perldoc for Net::LDAP::ModDN, for a start). Thanks for clues I can use.

- another intruder with the mooring of the heart of the Perl

Replies are listed 'Best First'.
Re: Changing a DN with Net::LDAP
by Prior Nacre V (Hermit) on Dec 03, 2004 at 14:17 UTC

    According to Net::LDAP::Message, the object returned by moddn() does not have a text() method. Perhaps you intended one of these:

    $err->error $err->error_desc $err->error_text

    Regards,

    PN5

Re: Changing a DN with Net::LDAP
by hsinclai (Deacon) on Dec 03, 2004 at 14:04 UTC
    Have you tried doing it without this bit:
    (my $new = $dn) =~ ...
    and just assigning $new its proper value? Also I'm not sure you need the ou= in there, as the values should be unique. With moddn you should not have to delete anything, it should alter the existing entry. Check that $entry contains what you think it should too..