Added Net::LDAP to the distribution for easier installs.

This commit is contained in:
JT Smith 2002-11-25 07:43:41 +00:00
parent f51b335d74
commit 223c014813
47 changed files with 15060 additions and 2 deletions

View file

@ -0,0 +1,165 @@
# $Id$
# Copyright (c) 2000 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::Paged;
use vars qw(@ISA $VERSION);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
$VERSION = "0.01";
use Net::LDAP::ASN qw(realSearchControlValue);
use strict;
sub init {
my($self) = @_;
delete $self->{asn};
unless (exists $self->{value}) {
$self->{asn} = {
size => $self->{size} || 0,
cookie => defined($self->{cookie}) ? $self->{cookie} : ''
};
}
$self;
}
sub cookie {
my $self = shift;
$self->{asn} ||= $realSearchControlValue->decode($self->{value});
if (@_) {
delete $self->{value};
return $self->{asn}{cookie} = defined($_[0]) ? $_[0] : '';
}
$self->{asn}{cookie};
}
sub size {
my $self = shift;
$self->{asn} ||= $realSearchControlValue->decode($self->{value});
if (@_) {
delete $self->{value};
return $self->{asn}{size} = shift || 0;
}
$self->{asn}{size};
}
sub value {
my $self = shift;
exists $self->{value}
? $self->{value}
: $self->{value} = $realSearchControlValue->encode($self->{asn});
}
1;
__END__
=head1 NAME
Net::LDAP::Control::Paged - LDAPv3 Paged results control object
=head1 SYNOPSIS
use Net::LDAP;
use Net::LDAP::Control::Paged;
use Net::LDAP::Constant qw( LDAP_CONTROL_PAGED );
$ldap = Net::LDAP->new( "ldap.mydomain.eg" );
$page = Net::LDAP::Control::Paged->new( size => 100 );
@args = ( base => "cn=subnets,cn=sites,cn=configuration,$BASE_DN",
scope => "subtree",
filter => "(objectClass=subnet)",
callback => \&process_entry, # Call this sub for each entry
control => [ $page ],
);
my $cookie;
while(1) {
# Perform search
my $mesg = $ldap->search( @args );
# Only continue on LDAP_SUCCESS
$mesg->code and last;
# Get cookie from paged control
my($resp) = $mesg->control( LDAP_CONTROL_PAGED ) or last;
$cookie = $resp->cookie or last;
# Set cookie in paged control
$page->cookie($cookie);
}
if ($cookie) {
# We had an abnormal exit, so let the server know we do not want any more
$page->cookie($cookie);
$page->size(0);
$ldap->search( @args );
}
=head1 DESCRIPTION
C<Net::LDAP::Control::Paged> provides an interface for the creation and manipulatrion
of objects that represent the C<pagedResultsControl> as described by RFC-2696.
=head1 CONSTRUCTOR ARGUMENTS
In addition to the constructor arguments described in
L<Net::LDAP::Control> the following are provided.
=over 4
=item cookie
The value to use as the cookie. This is not normally set when an object is
created, but is set from the cookie value returned bu the server. This associates
a search with a previous search, so the server knows to return the page
of entries following the entries it returned the previous time.
=item size
The page size that is required. This is the maximum number of entries that the
server will return to the search request.
=back
=head1 METHODS
As with L<Net::LDAP::Control> each constructor argument
described above is also avaliable 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.
=head1 SEE ALSO
L<Net::LDAP>,
L<Net::LDAP::Control>,
http://info.internet.isi.edu/in-notes/rfc/files/rfc2696.txt
=head1 AUTHOR
Graham Barr <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 2000 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.
=for html <hr>
I<$Id$>
=cut

View file

@ -0,0 +1,134 @@
# $Id$
# Copyright (c) 2001 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::ProxyAuth;
use vars qw(@ISA $VERSION);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
$VERSION = do { my @r=(q$Revision$=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
use Net::LDAP::ASN qw(proxyAuthValue);
use strict;
sub init {
my($self) = @_;
delete $self->{asn};
unless (exists $self->{value}) {
$self->{asn} = {
proxyDN => $self->{proxyDN} || '',
};
}
$self->{critical}=1;
$self;
}
sub proxyDN {
my $self = shift;
$self->{asn} ||= $proxyAuthValue->decode($self->{value});
if (@_) {
delete $self->{value};
return $self->{asn}{proxyDN} = shift || 0;
}
$self->{asn}{proxyDN};
}
sub value {
my $self = shift;
exists $self->{value}
? $self->{value}
: $self->{value} = $proxyAuthValue->encode($self->{asn});
}
1;
__END__
=head1 NAME
Net::LDAP::Control::ProxyAuth - LDAPv3 Proxy Authentication control object
=head1 SYNOPSIS
use Net::LDAP;
use Net::LDAP::Control::ProxyAuth;
$ldap = Net::LDAP->new( "ldap.mydomain.eg" );
$auth = Net::LDAP::Control::ProxyAuth->new( proxyDN => 'cn=me,ou=people,o=myorg.com' );
@args = ( base => "cn=subnets,cn=sites,cn=configuration,$BASE_DN",
scope => "subtree",
filter => "(objectClass=subnet)",
callback => \&process_entry, # Call this sub for each entry
control => [ $auth ],
);
while(1) {
# Perform search
my $mesg = $ldap->search( @args );
# Only continue on LDAP_SUCCESS
$mesg->code and last;
}
=head1 DESCRIPTION
C<Net::LDAP::Control::ProxyAuth> provides an interface for the creation and manipulation
of objects that represent the C<proxyauthorisationControl> as described by draft-weltman-ldapv3-proxy-05.txt.
=head1 CONSTRUCTOR ARGUMENTS
In addition to the constructor arguments described in
L<Net::LDAP::Control> the following are provided.
=over 4
=item proxyDN
The proxyDN that is required. This is the identity we are requesting operations to use
=back
=head1 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.
=head1 SEE ALSO
L<Net::LDAP>,
L<Net::LDAP::Control>,
http://info.internet.isi.edu/in-notes/rfc/files/rfc2696.txt
=head1 AUTHOR
Olivier Dubois, Swift sa/nv based on Net::LDAP::Control::Page from Graham Barr <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 2001 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.
=for html <hr>
I<$Id$>
=cut

View file

@ -0,0 +1,205 @@
# $Id$
# Copyright (c) 1999-2000 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::Sort;
use vars qw(@ISA $VERSION);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
$VERSION = "0.01";
use Net::LDAP::ASN qw(SortRequest);
use strict;
sub init {
my($self) = @_;
if (exists $self->{value}) {
$self->value($self->{value});
}
elsif (exists $self->{order}) {
$self->order(ref($self->{order}) ? @{$self->{order}} : $self->{order});
}
$self;
}
sub value {
my $self = shift;
if (@_) {
my $value = shift;
delete $self->{value};
delete $self->{order};
delete $self->{error};
my $asn = $SortRequest->decode($value);
unless ($asn) {
$self->{error} = $@;
return undef;
}
$self->{order} = [ map {
($_->{reverseOrder} ? "-" : "")
. $_->{type}
. (defined($_->{orderingRule}) ? ":$_->{orderingRule}" : "")
} @{$asn->{order}}];
return $self->{value} = $value;
}
unless (defined $self->{value}) {
$self->{value} = $SortRequest->encode(
order => [
map {
/^(-)?([^:]+)(?::(.+))?/;
{
type => $2,
(defined $1 ? (reverseOrder => 1) : ()),
(defined $3 ? (orderingRule => $3) : ())
}
} @{$self->{order} || []}
]
) or $self->{error} = $@;
}
$self->{value};
}
sub valid { exists shift->{order} }
sub order {
my $self = shift;
if (@_) {
# @_ can either be a list, or a single item.
# if a single item it can be a string, which needs
# to be split on spaces, or a reference to a list
#
# Each element has three parts
# leading - (optional)
# an attribute name
# :match-rule (optional)
my @order = (@_ == 1) ? split(/\s+/, $_[0]) : @_;
delete $self->{'value'};
delete $self->{order};
delete $self->{error};
foreach (@order) {
next if /^-?[^:]+(?::.+)?$/;
$self->{error} = "Bad order argument '$_'";
return;
}
$self->{order} = \@order;
}
return @{$self->{order}};
}
1;
__END__
=head1 NAME
Net::LDAP::Control::Sort - Server Side Sort (SSS) control object
=head1 SYNOPSIS
use Net::LDAP::Control::Sort;
use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);
$sort = Net::LDAP::Control::Sort->new(
order => "cn -phone"
);
$mesg = $ldap->search( @args, control => [ $sort ]);
($resp) = $mesg->control( LDAP_CONTROL_SORTRESULT );
print "Results are sorted\n" if $resp and !$resp->result;
=head1 DESCRIPTION
C<Net::LDAP::Control::Sort> is a sub-class of
L<Net::LDAP::Control>. It provides a class
for manipulating the LDAP Server Side Sort (SSS) request control
C<1.2.840.113556.1.4.473> as defined in RFC-2891
If the server supports sorting, then the response from a search
operation will include a sort result control. This control is handled
by L<Net::LDAP::Control::SortResult>.
=head1 CONSTRUCTOR ARGUMENTS
=over 4
=item order
A string which defines how entries may be sorted. It consists of
multiple directives, spearated by whitespace. Each directive describes how
to sort entries using a single attribute. If two entries have identical
attributes, then the next directive in the list is used.
Each directive specifies a sorting order as follows
-attributeType:orderingRule
The leading C<-> is optional, and if present indicates that the sorting order should
be reversed. C<attributeType> is the attribute name to sort by. C<orderingRule> is optional and
indicates the rule to use for the sort and should be valid for the given C<attributeType>.
Any one attributeType should only appear once in the sorting list.
B<Examples>
"cn" sort by cn using the default ordering rule for the cn attribute
"-cn" sort by cn using the reverse of the default ordering rule
"age cn" sort by age first, then by cn using the default ordering rules
"cn:1.2.3.4" sort by cn using the ordering rule defined as 1.2.3.4
=back
=head1 METHODS
As with L<Net::LDAP::Control> each constructor argument
described above is also avaliable 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.
=head1 SEE ALSO
L<Net::LDAP>,
L<Net::LDAP::Control::SortResult>,
L<Net::LDAP::Control>,
http://info.internet.isi.edu/in-notes/rfc/files/rfc2891.txt
=head1 AUTHOR
Graham Barr <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 1999-2000 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.
=for html <hr>
I<$Id$>
=cut

View file

@ -0,0 +1,178 @@
# $Id$
# Copyright (c) 1999-2000 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::SortResult;
use Net::LDAP::ASN qw(SortResult);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
sub init {
my($self) = @_;
if (exists $self->{value}) {
$self->{asn} = $SortResult->decode(delete $self->{value});
}
else {
$self->{asn} = { sortResult => delete $self->{result} };
$self->{asn}{attributeType} = delete $self->{attr} if exists $self->{attr};
}
$self;
}
sub value {
my $self = shift;
$self->{value} = $SortResult->encode($self->{asn});
}
sub result {
my $self = shift;
@_ ? ($self->{asn}{sortResult}=shift)
: $self->{asn}{sortResult};
}
sub attr {
my $self = shift;
@_ ? ($self->{asn}{attributeType}=shift)
: $self->{asn}{attributeType};
}
1;
__END__
=head1 NAME
Net::LDAP::Control::SortResult - Server Side Sort (SSS) result control object
=head1 SYNOPSIS
use Net::LDAP::Control::Sort;
use Net::LDAP::Constant qw(LDAP_CONTROL_SORTRESULT);
use Net::LDAP::Util qw(ldap_error_name);
$sort = Net::LDAP::Control::Sort->new(
order => "cn -age"
);
$mesg = $ldap->search( @args, control => [ $sort ]);
($resp) = $mesg->control( LDAP_CONTROL_SORTRESULT );
if ($resp) {
if ($resp->result) {
my $attr = $resp->attr;
print "Problem sorting, ",ldap_error_name($resp->result);
print " ($attr)" if $attr;
print "\n";
}
else {
print "Results are sorted\n";
}
}
else {
print "Server does not support sorting\n";
}
=head1 DESCRIPTION
C<Net::LDAP::Control::SortResult> is a sub-class of
L<Net::LDAP::Control>. It provides a class for
manipulating the LDAP sort request control C<1.2.840.113556.1.4.474>
as defined in RFC-2891
A sort result control will be returned by the server in response to
a search with a Server Side Sort control. If a sort result control is
not returned then the user may assume that the server does not support
sorting and the results are not sorted.
=head1 CONSTRUCTOR ARGUMENTS
=over 4
=item attr
If C<result> indicates that there was a problem with sorting and that problem was
due to one of the attributes specified in the sort control. C<attr> is set to
the name of the attribute causing the problem.
=item result
This is the result code that describes if the sort operation was sucessful. If will
be one of the result codes describes below.
=back
=head1 METHODS
As with L<Net::LDAP::Control> each constructor argument
described above is also avaliable 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.
=head1 RESULT CODES
Possible results from a sort request are listed below. See L<Net::LDAP::Constant> for
a definition of each.
=over 4
=item LDAP_SUCCESS
=item LDAP_OPERATIONS_ERROR
=item LDAP_TIMELIMIT_EXCEEDED
=item LDAP_STRONG_AUTH_REQUIRED
=item LDAP_ADMIN_LIMIT_EXCEEDED
=item LDAP_NO_SUCH_ATTRIBUTE
=item LDAP_INAPPROPRIATE_MATCHING
=item LDAP_INSUFFICIENT_ACCESS
=item LDAP_BUSY
=item LDAP_UNWILLING_TO_PERFORM
=item LDAP_OTHER
=back
=head1 SEE ALSO
L<Net::LDAP>,
L<Net::LDAP::Control::Sort>,
L<Net::LDAP::Control>,
http://info.internet.isi.edu/in-notes/rfc/files/rfc2891.txt
=head1 AUTHOR
Graham Barr <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 1999-2000 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.
=for html <hr>
I<$Id$>
=cut

403
lib/Net/LDAP/Control/VLV.pm Normal file
View file

@ -0,0 +1,403 @@
# $Id$
# Copyright (c) 2000 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 vars qw(@ISA $VERSION);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
$VERSION = "0.02";
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( sort => '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-03.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 avaliable 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>
attibutes 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 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 <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 2000 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.
=for html <hr>
I<$Id$>

View file

@ -0,0 +1,198 @@
# Copyright (c) 2000 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::VLVResponse;
use vars qw(@ISA $VERSION);
use Net::LDAP::Control;
@ISA = qw(Net::LDAP::Control);
$VERSION = "0.01";
use Net::LDAP::ASN qw(VirtualListViewResponse);
use strict;
sub init {
my($self) = @_;
if (exists $self->{value}) {
$self->value($self->{value});
}
else {
my $asn = $self->{asn} = {};
$asn->{targetPosition} = $self->{target} || 0;
$asn->{contentCount} = $self->{content} || 0;
$asn->{virtualListViewResult} = $self->{result} || 0;
$asn->{context} = $self->{context} || undef;
}
$self;
}
sub target {
my $self = shift;
if (@_) {
delete $self->{value};
return $self->{asn}{targetPosition} = shift;
}
$self->{asn}{targetPosition};
}
sub content {
my $self = shift;
if (@_) {
delete $self->{value};
return $self->{asn}{contentCount} = shift;
}
$self->{asn}{contentCount};
}
sub result {
my $self = shift;
if (@_) {
delete $self->{value};
return $self->{asn}{virtualListViewResult} = shift;
}
$self->{asn}{virtualListViewResult};
}
sub context {
my $self = shift;
if (@_) {
delete $self->{value};
return $self->{asn}{context} = shift;
}
$self->{asn}{context};
}
sub value {
my $self = shift;
if (@_) {
unless ($self->{asn} = $VirtualListViewResponse->decode($_[0])) {
delete $self->{value};
return undef;
}
$self->{value} = shift;
}
exists $self->{value}
? $self->{value}
: $self->{value} = $VirtualListViewResponse->encode($self->{asn});
}
1;
__END__
=head1 NAME
Net::LDAP::Control::VLVResponse -- LDAPv3 Virtual List View server response
=head1 SYNOPSIS
See L<Net::LDAP::Control::VLV>
=head1 DESCRIPTION
C<Net::LDAP::Control::VLVResponse> is a sub-class of L<Net::LDAP::Control>.
It provides a class for manipulating the LDAP Virtual List View Response control
C<>
If the server supports Virtual List Views, then the response from a search operation will
include a VLVResponse control.
=head1 CONSTRUCTOR ARGUMENTS
In addition to the constructor arguments described in
L<Net::LDAP::Control> the following are provided.
=over 4
=item content
An estimate of the number of entries in the complete list. This value should
be used in any subsequent Virtual List View control using the same list.
=item context
An arbitary value which is used to associate subsequent requests with the
request which this control is a response for. This value should be copied
by the client into the Virtual List View control for any subsequent
search that uses the same list.
=item result
A result code indicating the result of the Virtual List View request. This
may be any of the codes listed below.
=item target
The list offset of the target entry.
=back
=head1 METHODS
As with L<Net::LDAP::Control> each constructor argument
described above is also avaliable 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.
=head1 RESULT CODES
Possible results from a sort request are listed below. See L<Net::LDAP::Constant> for
a definition of each.
=over 4
=item LDAP_SUCCESS
=item LDAP_OPERATIONS_ERROR
=item LDAP_TIMELIMIT_EXCEEDED
=item LDAP_ADMIN_LIMIT_EXCEEDED
=item LDAP_INSUFFICIENT_ACCESS
=item LDAP_BUSY
=item LDAP_UNWILLING_TO_PERFORM
=item LDAP_OTHER
=item LDAP_SORT_CONTROL_MISSING
=item LDAP_INDEX_RANGE_ERROR
=back
=head1 SEE ALSO
L<Net::LDAP>,
L<Net::LDAP::Control>,
http://info.internet.isi.edu/in-notes/rfc/files/rfc2696.txt
=head1 AUTHOR
Graham Barr <gbarr@pobox.com>
Please report any bugs, or post any suggestions, to the perl-ldap mailing list
<perl-ldap-dev@lists.sourceforge.net>
=head1 COPYRIGHT
Copyright (c) 2000 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.
=for html <hr>
I<$Id$>
=cut