1# Copyright (c) 2008 Mathieu Parent <math.parent@gmail.com>. All rights reserved.
2# This program is free software; you can redistribute it and/or
3# modify it under the same terms as Perl itself.
4
5package Net::LDAP::Control::SyncState;
6
7use Net::LDAP::Control;
8
9our @ISA = qw(Net::LDAP::Control);
10our $VERSION = '0.04';
11
12use Net::LDAP::ASN qw(syncStateValue);
13use strict;
14
15sub init {
16  my($self) = @_;
17
18  if (exists $self->{value}) {
19    $self->{asn} = $syncStateValue->decode(delete $self->{value});
20  } else {
21    $self->{asn} = {
22      state => $self->{state} || '',
23      entryUUID => $self->{entryUUID} || '',
24      cookie => defined($self->{cookie}) ? $self->{cookie} : '',
25    };
26  }
27
28  $self;
29}
30
31sub state {
32  my $self = shift;
33  $self->{asn} ||= $syncStateValue->decode($self->{value});
34  if (@_) {
35    delete $self->{value};
36    return $self->{asn}{state} = shift || 0;
37  }
38  $self->{asn}{state};
39}
40
41sub entryUUID {
42  my $self = shift;
43  $self->{asn} ||= $syncStateValue->decode($self->{value});
44  if (@_) {
45    delete $self->{value};
46    return $self->{asn}{entryUUID} = shift || 0;
47  }
48  $self->{asn}{entryUUID};
49}
50
51sub cookie {
52  my $self = shift;
53  $self->{asn} ||= $syncStateValue->decode($self->{value});
54  if (@_) {
55    delete $self->{value};
56    return $self->{asn}{cookie} = shift || 0;
57  }
58  $self->{asn}{cookie};
59}
60
61sub value {
62  my $self = shift;
63
64  exists $self->{value}
65    ? $self->{value}
66    : $self->{value} = $syncStateValue->encode($self->{asn});
67}
68
691;
70
71
72__END__
73
74=head1 NAME
75
76Net::LDAP::Control::SyncState - LDAPv3 Sync State control object
77
78=head1 SYNOPSIS
79
80See L<Net::LDAP::Control::SyncRequest>
81
82=head1 DESCRIPTION
83
84C<Net::LDAP::Control::SyncState> provides an interface for the creation and
85manipulation of objects that represent the C<Sync State Control> as described
86by RFC 4533.
87
88=head1 CONSTRUCTOR ARGUMENTS
89
90In addition to the constructor arguments described in
91L<Net::LDAP::Control> the following are provided.
92
93=over 4
94
95=item state
96
97=item entryUUID
98
99=item cookie
100
101=back
102
103=head1 METHODS
104
105As with L<Net::LDAP::Control> each constructor argument
106described above is also available as a method on the object which will
107return the current value for the attribute if called without an argument,
108and set a new value for the attribute if called with an argument.
109
110=head1 SEE ALSO
111
112L<Net::LDAP>,
113L<Net::LDAP::Control>,
114L<Net::LDAP::Control::SyncRequest>,
115L<Net::LDAP::Control::SyncDone>,
116http://www.ietf.org/rfc/rfc4533.txt
117
118=head1 AUTHOR
119
120Mathieu Parent E<lt>math.parent@gmail.comE<gt>
121
122Please report any bugs, or post any suggestions, to the perl-ldap mailing list
123E<lt>perl-ldap@perl.orgE<gt>
124
125=head1 COPYRIGHT
126
127Copyright (c) 2008 Mathieu Parent. All rights reserved. This program is
128free software; you can redistribute it and/or modify it under the same
129terms as Perl itself.
130
131=cut
132
133