[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 5 package Net::LDAP::Control::SyncState; 6 7 use vars qw(@ISA $VERSION); 8 use Net::LDAP::Control; 9 10 @ISA = qw(Net::LDAP::Control); 11 $VERSION = "0.02"; 12 13 use Net::LDAP::ASN qw(syncStateValue); 14 use strict; 15 16 sub init { 17 my($self) = @_; 18 19 if (exists $self->{value}) { 20 $self->{asn} = $syncStateValue->decode(delete $self->{value}); 21 } else { 22 $self->{asn} = { 23 state => $self->{state} || '', 24 entryUUID => $self->{entryUUID} || '', 25 cookie => defined($self->{cookie}) ? $self->{cookie} : '', 26 }; 27 } 28 29 $self; 30 } 31 32 sub state { 33 my $self = shift; 34 $self->{asn} ||= $syncStateValue->decode($self->{value}); 35 if (@_) { 36 delete $self->{value}; 37 return $self->{asn}{state} = shift || 0; 38 } 39 $self->{asn}{state}; 40 } 41 42 sub entryUUID { 43 my $self = shift; 44 $self->{asn} ||= $syncStateValue->decode($self->{value}); 45 if (@_) { 46 delete $self->{value}; 47 return $self->{asn}{entryUUID} = shift || 0; 48 } 49 $self->{asn}{entryUUID}; 50 } 51 52 sub cookie { 53 my $self = shift; 54 $self->{asn} ||= $syncStateValue->decode($self->{value}); 55 if (@_) { 56 delete $self->{value}; 57 return $self->{asn}{cookie} = shift || 0; 58 } 59 $self->{asn}{cookie}; 60 } 61 62 sub value { 63 my $self = shift; 64 65 exists $self->{value} 66 ? $self->{value} 67 : $self->{value} = $syncStateValue->encode($self->{asn}); 68 } 69 70 1; 71 72 73 __END__ 74 75 =head1 NAME 76 77 Net::LDAP::Control::SyncState - LDAPv3 Sync State control object 78 79 =head1 SYNOPSIS 80 81 use Net::LDAP; 82 use Net::LDAP::Control::SyncRequest; 83 use Net::LDAP::Constant qw( 84 LDAP_SYNC_REFRESH_ONLY 85 LDAP_SYNC_REFRESH_AND_PERSIST 86 LDAP_SUCCESS ); 87 88 $ldap = Net::LDAP->new( "ldap.mydomain.eg" ); 89 90 $req = Net::LDAP::Control::SyncRequest->new( mode => LDAP_SYNC_REFRESH_ONLY ); 91 my $mesg = $ldap->search(base=> 'dc=mydomain,dc='eg', 92 scope => 'sub', 93 control => [ $req ], 94 callback => \&searchCallback, # call for each entry 95 filter => "(objectClass=*)", 96 attrs => [ '*']); 97 sub searchCallback { 98 my $message = shift; 99 my $entry = shift; 100 my @controls = $message->control; 101 102 if($controls[0]->isa('Net::LDAP::Control::SyncState')) { 103 print "Received Sync State Control\n"; 104 print $entry->dn()."\n"; 105 print 'State: '.$controls[0]->state."\n".', entryUUID: '.$controls[0]->entryUUID.', cookie: '.$controls[0]->cookie; 106 } elsif($controls[0]->isa('Net::LDAP::Control::SyncDone')) { 107 print "Received Sync Done Control\n"; 108 print 'Cookie: '.$controls[0]->cookie.', refreshDeletes: '.$controls[0]->refreshDeletes; 109 } 110 } 111 112 =head1 DESCRIPTION 113 114 C<Net::LDAP::Control::SyncState> provides an interface for the creation and 115 manipulation of objects that represent the C<Sync State Control> as described 116 by RFC 4533. 117 118 =head1 CONSTRUCTOR ARGUMENTS 119 120 In addition to the constructor arguments described in 121 L<Net::LDAP::Control> the following are provided. 122 123 =over 4 124 125 =item state 126 127 =item entryUIID 128 129 =item cookie 130 131 =back 132 133 =head1 METHODS 134 135 As with L<Net::LDAP::Control> each constructor argument 136 described above is also avaliable as a method on the object which will 137 return the current value for the attribute if called without an argument, 138 and set a new value for the attribute if called with an argument. 139 140 =head1 SEE ALSO 141 142 L<Net::LDAP>, 143 L<Net::LDAP::Control>, 144 L<Net::LDAP::Control::SyncRequest>, 145 L<Net::LDAP::Control::SyncDone>, 146 http://www.ietf.org/rfc/rfc4533.txt 147 148 =head1 AUTHOR 149 150 Mathieu Parent E<lt>math.parent@gmail.comE<gt> 151 152 Please report any bugs, or post any suggestions, to the perl-ldap mailing list 153 E<lt>perl-ldap@perl.orgE<gt> 154 155 =head1 COPYRIGHT 156 157 Copyright (c) 2008 Mathieu Parent. All rights reserved. This program is 158 free software; you can redistribute it and/or modify it under the same 159 terms as Perl itself. 160 161 =cut 162
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |