From: Jim H. <ha...@us...> - 2000-08-29 13:49:47
|
Graham, I applaud your trying to make get or a rename of it function more as expected by an inexperienced person. As much as I dislike using longis names when short ones are great, I think the approach of deprecating "get" is correct. Note that you used "get" instead of get_value twice in the doc below, though. Once in Then a get for attribute "name" with alloptions set would return and again in my @entry = $entr->get($field); --Jim On Tue, 29 Aug 2000, Graham Barr wrote: > On Sat, Aug 26, 2000 at 12:33:32PM -0700, Yann Ramin wrote: > > Hi, > > > > Using the following code snippet under Net::LDAP 0.19 worked fine, but > > once I went to 0.20, it broke, and is now returning an array??? Is there > > something wrong with my code? > > In 0.20 ->get was changed to match it's documentation. However it > seems that what get now returns is not what is "expected" > > In the version in CVS, and what will be in 0.21, ->get has been > returned to it's previous implementation, but has also been > depricated. > > ->get has been replaced by ->get_value which is described below. > > I would appriciate any feedback on this. > > Graham. > > > =item get_value ( ATTR [, OPTIONS ] ) > > Get the values for the attribute ATTR. In a list context returns all > values for the given attribute, or the empty list if the attribute does > not exist. In a scalar context returns the first value for the attribute > or undef if the attribute does not exist. > > The return value may be changed by OPTIONS, which is a list of name => value > pairs, valid options are :- > > =over 4 > > =item alloptions > > If TRUE then the result will be a hash reference. The keys of the hash > will be the options and the hash value will be the values for those attributes. > For example if an entry had > > name: Graham Barr > name;en-us: Bob > > Then a get for attribute "name" with alloptions set would return > > { > '' => [ 'Graham Barr' ], > ';en-us' => [ 'Bob' ] > } > > =item asref > > If TRUE then the result will be a reference to an array containing all the > values for the attribute, or undef if the attribute does not exist. > > =back > > B<NOTE>: In the interest of performance the array references returned by C<get_value> > are references to structures held inside the entry object. These values and > thier contents should B<NOT> be modified directly. > > > $ref is the DN, and $field is usualy 'cn' or 'uidnumber', both of which > > exist. > > > > sub get_user_var { > > my ($self, $ref, $field) = @_; > > > > my $mesg = $self->{LDAP}->search ( > > base => $ref, > > filter => "(objectclass=*)" > > ); > > > > my @entries = $mesg->entries; > > if (!@entries) { return; } > > my $entr = $entries[0]; > > my @entry = $entr->get($field); > > my $e = $entry[0]; > > return $e; > > > > } > |