From: Chris R. <chr...@me...> - 2002-01-29 17:15:52
|
Chris Winters <ch...@cw...> wrote: > On Tue, 2002-01-29 at 10:19, Edd Dawson wrote: >> I have a routine i use for changing users passwords, and i wanted to put >> in some code so i can check the password was successfully updated, so i >> checked the online docs, and came up with the following : >> >> my $result = $ldap->modify( $dn, replace => { 'userpassword' >> => $new_password }); >> >> i was expecting $result to contain either 1 or 0 depending on whether >> the operation was successful, but instead get >> "Net::LDAP::Modify=HASH(0x88be34c)" now i know what i'm doing wrong is >> probably so stupidly basic.. but i can;t figure out why it doesn;t >> work!!!! > > Just try: > > my $result = $ldap->modify( $dn, > replace => { 'userpassword' => > $new_password }); if ( $result->code ) { > die "Error from modify: ", $result->error; > } > > The POD for Net::LDAP has another example at the bottom of the SYNOPSIS. The reason for that is that LDAP operations might result in several things, like referrals, permissions errors, schema violations, search results etc etc. That's why the operation methods return objects (Net::LDAP::Message) which you then query to find out what happened (Net::LDAP::Message::code). > Chris Cheers, Chris (a different one) |