From: Graham B. <gb...@po...> - 2000-10-16 10:00:25
|
On Mon, Oct 16, 2000 at 10:19:21AM +0100, Chris Ridd wrote: > Werner Reisberger <we...@pu...> wrote: > > On Fri, Oct 13, 2000 at 04:03:25PM -0500, Mark Wilcox wrote: > >> The value of the hash would have to contain an array. > >> > >> like this: > >> my $array = ['value','value','value']; > >> or > >> $array->[0] = 'value'; > >> $array->[1] = 'value'; > > > > OK, this way I could create several attribute/value pairs where the > > attribute (key) doesn't change but I want to have several different > > attributes in my hash. Example: > > > > dc => 'mydom.com', > > sn => 'Brown', > > cn => 'C B' > > > > I want to put these attribute/value pairs into a structure (hash ...) and > > supply this structure to the attrs method to avoid writing each > > attribute/value pair seperately: > > > > $ldap->add ( > > dn => $dn, > > attrs => [%myhash] ); > > > > I used an array of anonymous hashes and an array and a hash within the > > anonymous array. First case doesn't work at all, in the last two trials > > only one attribute is added to the entry. > > > > Werner > > Couldn't you just use: > > $ldap->add ( dn => $dn, > attrs => [ keys %myhash ] ); No, thats not right. Look at the example in the docs $mesg = $ldap->add( $DN, attrs => [ name => 'Graham Barr', attr => 'value1', attr => 'value2', multi => [qw(value1 value2)] ] ); This adds 4 attributes, each with a single value except 'multi' which has multiple values. So if %myhash has an entry per attribute. The values need to be either the value (for single valued attributes) or a reference to an array of values (for multi or singled-valued attributes) Graham. |