http://www.perlmonks.org?node_id=990395

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

Hi Perl Gurus, i have written the script below to modify attribute on LDAP Directory. But i cant make the changes

#!/usr/bin/perl use Net::LDAP; $ldap = new Net::LDAP('localhost') or die "$@"; $ldap->bind( dn => 'uid=xxx,ou=org,o=xxx.com', password => 'secret' ) || die $@; my $dn = "uid=atype,ou=org,o=com"; my $description = "banana"; $msg = $ldap->modify ( $dn, replace => { 'description' => $description } ) || warn "Failed to modify entry. $!"; print "msg is $msg\n"; $ldap->unbind;

i received the following error, when i run the perl script and the attribute not updated on LDAP Directory

msg is Net::LDAP::Modify=HASH(0x1bfe7a4)

Can you please let me know what is my mistake in here, or how to make sure the update take place on LDAP

Thank you in advanced.

Replies are listed 'Best First'.
Re: LDAP attribute modifciation failed
by Corion (Patriarch) on Aug 29, 2012 at 07:30 UTC

    The Net::LDAP documentation shows the following approach for error checking. Why are you not using it?

    $mesg = $ldap->search( # perform a search base => "c=US", filter => "(&(sn=Barr) (o=Texas Instruments))" ); $mesg->code && die $mesg->error;

      Not sure how to use it, and where to use it.

      I read the reference still not understand much

        If you don't know how and where to use that snippet, how did you come up with your original program? Maybe it's now time to learn to program, and also time to learn about LDAP?

        The code snippet I quoted is very, very similar to a part of the program you already posted. I recommend you learn to recognize similarities, and also recognize differences, and learn to modify code according to similarity and difference.