Billy Joedono wrote:

> script, consistently. I think that's because I read multiple values
> incorrectly, thus when the copy is written to the replica, it gives the
> "segmentation fault" error. I inserted the piece of code that I think is
> the culprit, but I'm stuck as to what needs to be corrected. I wonder if
> you gurus could give me some pointers.

What version of PerLDAP are you using? Version of Perl? Platform? Also, do you
know when it segfaults? Does it happen in the call to |update()|?


> and what I want to do is to copy each and every attributes and the
> respective values from %Entry into %Existing, with the piece of code follows:
>
> *************
>    if ($Existing) {
>        foreach $attr (@{$Entry->{"_oc_order_"}})
>        {
>          if (($attr =~ /^_.+_$/) || ($attr eq 'jpegphoto') || ($attr eq
> 'usercertificate')) {
>          next;
>          }

In later versions of PerLDAP, it should work doing just

foreach $attr (keys(%{$entry}) {
   next if (($attr eq 'jpegphoto') || ($attr eq 'usercertificate'));
   ...

PerLDAP will automatically make sure that the |keys()| call only return
appropriate attributes.


> # Add all attributes values of the grabbed record into the found record
>          if (defined($Existing->{$attr})) {
>            $Existing->{$attr}= [ @{$Entry->{$attr}} ];

You might want to use |setValues()| here, but this should work to...


>            $Existing->addValue("$attr", [ @{$Entry->{$attr}} ]);
>          } # End if (defined ...

Hmmm, this doesn't look right, |addValue()| doesn't expect to take an array as
the value... This might have undesired effects if the attribute is multi-value.
You really need to loop through all the values here, and |addValue()| them one by
one.

If you look at the definition of |addValue()|, it actully takes optional 3rd and
4th arguments, to force an add, and to normalize the value (respectively).

This is ugly and demented, and in v2.0 argument passing is totally rewritten to
be more "perlish" and flexible. Sorry about that, my bad.


Let me know how it goes, we could really use some more information to debug this
I think. :)

-- Leif


Reply via email to