[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3-unattended/var/se3/unattended/install/linuxaux/opt/perl/lib/site_perl/5.10.0/Net/LDAP/Control/ -> SyncDone.pm (source)

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


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1