1package Net::LDAP::Extension::Refresh;
2require Net::LDAP::Extension;
3
4our @ISA = qw(Net::LDAP::Extension);
5our $VERSION = '0.04';
6
7use Convert::ASN1;
8
9my $refreshReq = Convert::ASN1->new;
10$refreshReq->prepare(q<SEQUENCE {
11                     entryName    [0] OCTET STRING, -- originally: LDAPDN
12                     requestTtl   [1] INTEGER
13                     }>);
14
15my $refreshResp = Convert::ASN1->new;
16$refreshResp->prepare(q<SEQUENCE {
17                      responseTtl [1] INTEGER
18                      }>);
19
20sub Net::LDAP::refresh {
21  my $ldap = shift;
22  my %opt = @_;
23
24  my $res = $ldap->extension (
25    name => '1.3.6.1.4.1.1466.101.119.1',
26    value => $refreshReq->encode(\%opt),
27    ($opt{control} ? (control => $opt{control}) : ())
28  );
29
30  bless $res;
31}
32
33sub get_ttl {
34  my $self = shift;
35  my $out = $refreshResp->decode($self->response);
36  $out->{responseTtl};
37}
381;
39
40__END__
41
42=head1 NAME
43
44Net::LDAP::Extension::Refresh - LDAPv3 Refresh extension object (RFC 2589)
45
46=head1 SYNOPSIS
47
48 use Net::LDAP;
49 use Net::LDAP::Extension::Refresh;
50
51 $ldap = Net::LDAP->new('localhost');
52 $ldap->bind('cn=admin,dc=example,dc=com', password => 'password');
53
54 $mesg = $ldap->refresh(entryName => 'cn=dynamic,dc=example,dc=com',
55        requestTtl => 100);
56 die "error :", $mesg->code(), ": ", $mesg->error()  if ($mesg->code());
57 print "TTL changed to ", $mesg->get_ttl(), "\n";
58
59=head1 DESCRIPTION
60
61C<Net::LDAP::Extension::Refresh> implements the C<Refresh> extended LDAPv3
62operation as described in RFC 2589
63
64It implements no object by itself but extends the L<Net::LDAP> object
65by another method:
66
67=head1 METHODS
68
69=over 4
70
71=item refresh ( OPTIONS )
72
73Send a refresh operation for an object.
74
75OPTIONS is a list of key/value pairs. The following keys are recognized:
76
77=over 4
78
79=item entryName
80
81This option contains the object to refresh. It must be a DN.
82
83=item requestTtl
84
85This option contains the TTL in seconds requested. The server may choose to
86set another value as stated in RFC 2589
87
88=back
89
90=item get_ttl ( )
91
92Return the TTL set by the server during the previous C<refresh> call.
93
94This method is a method of the L<Net::LDAP::Message> response object
95returned in reply to C<refresh()> in case the C<refresh()> call succeeded.
96
97=back
98
99=head1 SEE ALSO
100
101L<Net::LDAP>,
102L<Net::LDAP::Extension>
103
104=head1 AUTHOR
105
106Etienne Bagnoud E<lt>etienne.bagnoud@irovision.chE<gt>
107Adapted from Graham Barr L<Net::LDAP::Extension::SetPassword>
108Documentation adapted from Peter Marschall L<Net::LDAP::Extension::SetPassword>
109
110Please report any bugs, or post any suggestions, to the perl-ldap
111mailing list E<lt>perl-ldap@perl.orgE<gt>
112
113=head1 COPYRIGHT
114
115Copyright (c) 2010 Etienne Bagnoud. All rights reserved. This program is
116free software; you can redistribute it and/or modify it under the same
117terms as Perl itself.
118
119=cut
120
121