This file is indexed.

/usr/share/perl5/Net/LDAP/Control/VLV.pm is in libnet-ldap-perl 1:0.6500+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# Copyright (c) 2000-2004 Graham Barr <gbarr@pobox.com>. All rights reserved.
# This program is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.

package Net::LDAP::Control::VLV;

use Net::LDAP::Control;

our @ISA = qw(Net::LDAP::Control);
our $VERSION = '0.06';

use Net::LDAP::ASN qw(VirtualListViewRequest);
use strict;

sub init {
  my($self) = @_;

  # VLVREQUEST should always have a critical of true
  $self->{critical} = 1  unless exists $self->{critical};

  if (exists $self->{value}) {
    $self->value($self->{value});
  }
  else {
    my $asn = $self->{asn} = {};

    $asn->{beforeCount} = $self->{before} || 0;
    $asn->{afterCount}  = $self->{after} || 0;
    if (exists $self->{assert}) {
      $asn->{byValue} = $self->{assert};
    }
    else {
      $asn->{byoffset} = {
 	offset => $self->{offset} || 0,
	contentCount => $self->{content} || 0
      };
    }
  }

  $self;
}

sub before {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    return $self->{asn}{beforeCount} = shift;
  }
  $self->{asn}{beforeCount};
}

sub after  {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    return $self->{asn}{afterCount} = shift;
  }
  $self->{asn}{afterCount};
}

sub content {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    if (exists $self->{asn}{byValue}) {
      delete $self->{asn}{byValue};
      $self->{asn}{byoffset} = { offset => 0 };
    }
    return $self->{asn}{byoffset}{contentCount} = shift;
  }
  exists $self->{asn}{byoffset}
    ? $self->{asn}{byoffset}{contentCount}
    : undef;
}

sub assert {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    delete $self->{asn}{byoffset};
    return $self->{asn}{byValue} = shift;
  }
  exists $self->{asn}{byValue}
    ? $self->{asn}{byValue}
    : undef;
}

sub context {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    return $self->{asn}{contextID} = shift;
  }
  $self->{asn}{contextID};
}

# Update self with values from a response

sub response {
  my $self = shift;
  my $resp = shift;

  my $asn = $self->{asn};

  $asn->{contextID} = $resp->context;
  $asn->{byoffset} = {
    offset => $resp->target,
    contentCount => $resp->content
  };
  delete $asn->{byValue};

  1;
}

sub offset {
  my $self = shift;
  if (@_) {
    delete $self->{value};
    if (exists $self->{asn}{byValue}) {
      delete $self->{asn}{byValue};
      $self->{asn}{byoffset} = { contentCount => 0 };
    }
    return $self->{asn}{byoffset}{offset} = shift;
  }
  exists $self->{asn}{byoffset}
    ? $self->{asn}{byoffset}{offset}
    : undef;
}

sub value {
  my $self = shift;

  if (@_) {
    unless ($self->{asn} = $VirtualListViewRequest->decode($_[0])) {
      delete $self->{value};
      return undef;
    }
    $self->{value} = shift;
  }

  exists $self->{value}
    ? $self->{value}
    : $self->{value} = $VirtualListViewRequest->encode($self->{asn});
}

sub scroll {
  my $self = shift;
  my $n = shift;
  my $asn = $self->{asn};
  my $byoffset = $asn->{byoffset}
    or return undef;
  my $offset = $byoffset->{offset} + $n;
  my $content;

  if ($offset < 1) {
    $asn->{afterCount} += $asn->{beforeCount};
    $asn->{beforeCount} = 0;
    $offset = $byoffset->{offset} = 1;
  }
  elsif ($byoffset->{contentCount} and $asn->{afterCount}+$offset >$byoffset->{contentCount}) {
    if ($offset > $byoffset->{contentCount}) {
      $offset = $byoffset->{offset} = $byoffset->{contentCount};
      $asn->{beforeCount} += $asn->{afterCount};
      $asn->{afterCount} = 0;
    }
    else {
      my $tmp = $byoffset->{contentCount} - $offset;
      $asn->{beforeCount} += $tmp;
      $asn->{afterCount}  -= $tmp;
      $byoffset->{offset} = $offset;
    }
  }
  else {
    $byoffset->{offset} = $offset;
  }

  $offset;
}

sub scroll_page {
  my $self = shift;
  my $n = shift;
  my $asn = $self->{asn};
  my $page_size = $asn->{beforeCount} + $asn->{afterCount} + 1;

  $self->scroll( $page_size * $n);
}

sub start {
  my $self = shift;
  my $asn = $self->{asn};
  $asn->{afterCount} += $asn->{beforeCount};
  $asn->{beforeCount} = 0;
  $self->offset(1);
}

sub end {
  my $self = shift;
  my $asn = $self->{asn};
  my $content = $self->content || 0;

  $asn->{beforeCount} += $asn->{afterCount};
  $asn->{afterCount} = 0;
  $self->offset($content);
}

1;

__END__

=head1 NAME

Net::LDAP::Control::VLV - LDAPv3 Virtual List View control object

=head1 SYNOPSIS

 use Net::LDAP;
 use Net::LDAP::Control::VLV;
 use Net::LDAP::Constant qw( LDAP_CONTROL_VLVRESPONSE );

 $ldap = Net::LDAP->new( "ldap.mydomain.eg" );

 # Get the first 20 entries
 $vlv  = Net::LDAP::Control::VLV->new(
	   before  => 0,	# No entries from before target entry
	   after   => 19,	# 19 entries after target entry
	   content => 0,	# List size unknown
	   offset  => 1,	# Target entry is the first
	 );
 $sort = Net::LDAP::Control::Sort->new( order => 'cn' );

 @args = ( base     => "o=Ace Industry, c=us",
	   scope    => "subtree",
	   filter   => "(objectClass=inetOrgPerson)",
	   callback => \&process_entry, # Call this sub for each entry
	   control  => [ $vlv, $sort ],
 );

 $mesg = $ldap->search( @args );

 # Get VLV response control
 ($resp)  = $mesg->control( LDAP_CONTROL_VLVRESPONSE )  or die;
 $vlv->response( $resp );

 # Set the control to get the last 20 entries
 $vlv->end;

 $mesg = $ldap->search( @args );

 # Get VLV response control
 ($resp)  = $mesg->control( LDAP_CONTROL_VLVRESPONSE )  or die;
 $vlv->response( $resp );

 # Now get the previous page
 $vlv->scroll_page( -1 );

 $mesg = $ldap->search( @args );

 # Get VLV response control
 ($resp)  = $mesg->control( LDAP_CONTROL_VLVRESPONSE )  or die;
 $vlv->response( $resp );

 # Now page with first entry starting with "B" in the middle
 $vlv->before(9);	# Change page to show 9 before
 $vlv->after(10);	# Change page to show 10 after
 $vlv->assert("B");	# assert "B"

 $mesg = $ldap->search( @args );

=head1 DESCRIPTION

C<Net::LDAP::Control::VLV> provides an interface for the creation and
manipulation of objects that represent the Virtual List View as described
by draft-ietf-ldapext-ldapv3-vlv-09.txt.

When using a Virtual List View control in a search, it must be accompanied by a sort
control. See L<Net::LDAP::Control::Sort>

=cut

##
## Need some blurb here to describe the VLV control. Maybe extract some simple
## describtion from the draft RFC
##

=head1 CONSTRUCTOR ARGUMENTS

In addition to the constructor arguments described in
L<Net::LDAP::Control> the following are provided.

=over 4

=item after

Set the number of entries the server should return from the list after
the target entry.

=item assert

Set the assertion value user to locate the target entry. This value should
be a legal value to compare with the first attribute in the sort control
that is passed with the VLV control. The target entry is the first entry
in the list which is greater than or equal the assert value.

=item before

Set the number of entries the server should return from the list before
the target entry.

=item content

Set the number of entries in the list. On the first search this value
should be set to zero. On subsequent searches it should be set to the
length of the list, as returned by the server in the VLVResponse control.

=item context

Set the context identifier.  On the first search this value should be
set to zero. On subsequent searches it should be set to the context
value returned by the server in the VLVResponse control.

=item offset

Set the offset of the target entry.

=back

=head2 METHODS

As with L<Net::LDAP::Control> each constructor argument
described above is also available as a method on the object which will
return the current value for the attribute if called without an argument,
and set a new value for the attribute if called with an argument.

The C<offset> and C<assert> attributes are mutually exclusive. Setting
one or the other will cause previous values set by the other to
be forgotten. The C<content> attribute is also associated with the
C<offset> attribute, so setting C<assert> will cause any C<content>
value to be forgotten.

=over 4

=item end

Set the target entry to the end of the list. This method will change the C<before>
and C<after> attributes so that the target entry is the last in the page.

=item response VLV_RESPONSE

Set the attributes in the control as per VLV_RESPONSE. VLV_RESPONSE should be a control
of type L<Net::LDAP::Control::VLVResponse> returned
from the server. C<response> will populate the C<context>, C<offset> and C<content>
attributes of the control with the values from VLV_RESPONSE. Because this sets the
C<offset> attribute, any previous setting of the C<assert> attribute will be forgotten.

=item scroll NUM

Move the target entry by NUM entries. A positive NUM will move the target entry towards
the end of the list and a negative NUM will move the target entry towards the
start of the list. Returns the index of the new target entry, or C<undef> if the current target
is identified by an assertion.

C<scroll> may change the C<before> and C<after> attributes if the scroll value would
cause the page to go off either end of the list. But the page size will be maintained.

=item scroll_page NUM

Scroll by NUM pages. This method simple calculates the current page size and calls
C<scroll> with C<NUM * $page_size>

=item start

Set the target entry to the start of the list. This method will change the C<before> and C<after>
attributes to the target entry is the first entry in the page.

=back

=head1 SEE ALSO

L<Net::LDAP>,
L<Net::LDAP::Control>,
L<Net::LDAP::Control::Sort>,
L<Net::LDAP::Control::VLVResponse>

=head1 AUTHOR

Graham Barr E<lt>gbarr@pobox.comE<gt>

Please report any bugs, or post any suggestions, to the perl-ldap mailing list
E<lt>perl-ldap@perl.orgE<gt>

=head1 COPYRIGHT

Copyright (c) 2000-2004 Graham Barr. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.

=cut