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


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