Hi,
On Tuesday 24 August 2004 02:20, Drue Reeves wrote:
> I am having problems with Modify returning a ZERO (0) even though I know
> the function isn't being called correctly. And, the directory service isn't
> being updated.
>
> What I am trying to do is sort-of funky...I'm trying to modify the
> directory based on the hash method. However, I am building the function
> based on parameters passed on the command line. In any case, here's how the
> has gets built:
>
> my %ReplaceHash = ( $attribute=>$value1 );
>
> I know this is probably wrong but, I figured that I'd try it and see what
> modify returns. That way, I might be able to figure out if it was the
> attribute name or value that was wrong. Then I call:
>
> my $result = LDAPmodifyUsingHash ( $ldap, $dn, \%ReplaceHash, $operation
> );
>
> sub LDAPmodifyUsingHash
> {
> my ($ldap, $dn, $whatToChange, $howToChange ) = @_;
> my $result = $ldap->modify ( $dn,
> $howToChange => { %$whatToChange }
> );
> return $result;
> }
As long as $operation is one of 'add', 'delete' or 'replace' this look O.K.
to me (although instead of { %$whatToChange } you might simply write
$whatToChange, as $whatToChange is already a hashref)
Please note: $result is a Net::LDAP::Message object.
> In both the subroutine and the main funtion, result is ZERO (0). Why? I
> expected an "Unknown attribute" or something.
How do you test for ZERO ?
By calling $result->code() ?
Then the resulting 0 stands for LDAP_SUCCESS, which may be alright provided
you gave a legal operation, a legal attribute name, a value conforming to the
attribute's syntax (resp. an existing value when deleting) , an existing $dn,
your LDAP server was up and you were bound with a DN that was allowed to
perform this operation.
Unfortunately you did not send these parameters in your mail, which makes
answering the question a bit of guesswork.
Peter
--
Peter Marschall
eMail: [EMAIL PROTECTED]