[ 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/ -> EntryChange.pm (source)

   1  # Copyright (c) 2004 Peter Marschall <peter@adpm.de>. 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::EntryChange;
   6  
   7  use vars qw(@ISA $VERSION);
   8  use Net::LDAP::Control;
   9  
  10  @ISA = qw(Net::LDAP::Control);
  11  $VERSION = "0.01";
  12  
  13  use Net::LDAP::ASN qw(EntryChangeNotification);
  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        changeTypes  => $self->{changeType} || '0',
  24        previousDN   => $self->{previousDN} || '',
  25        changeNumber => $self->{changeNumber} || '0',
  26      };
  27    }
  28  
  29    $self;
  30  }
  31  
  32  sub changeType {
  33    my $self = shift;
  34    $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  35    if (@_) {
  36      delete $self->{value};
  37      return $self->{asn}{changeType} = shift || 0;
  38    }
  39    $self->{asn}{changeType};
  40  }
  41  
  42  sub previousDN {
  43    my $self = shift;
  44    $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  45    if (@_) {
  46      delete $self->{value};
  47      return $self->{asn}{previousDN} = shift || '';
  48    }
  49    $self->{asn}{previousDN};
  50  }
  51  
  52  sub changeNumber {
  53    my $self = shift;
  54    $self->{asn} ||= $EntryChangeNotification->decode($self->{value});
  55    if (@_) {
  56      delete $self->{value};
  57      return $self->{asn}{changeNumber} = shift || 0;
  58    }
  59    $self->{asn}{changeNumber};
  60  }
  61  
  62  sub value {
  63    my $self = shift;
  64  
  65    exists $self->{value}
  66      ? $self->{value}
  67      : $self->{value} = $EntryChangeNotification->encode($self->{asn});
  68  }
  69  
  70  1;
  71  
  72  __END__
  73  
  74  =head1 NAME
  75  
  76  Net::LDAP::Control::EntryChange - LDAPv3 Entry Change Notification control object
  77  
  78  =head1 SYNOPSIS
  79  
  80   use Net::LDAP;
  81   use Net::LDAP::Control::PersistentSearch;
  82   use Net::LDAP::Constant qw(LDAP_CONTROL_ENTRYCHANGE);
  83  
  84   $ldap = Net::LDAP->new( "ldap.mydomain.eg" );
  85  
  86   $persist = Net::LDAP::Control::PersistentSearch->new( changeTypes => 15,
  87                                                         changesOnly => 1,
  88                                                         returnECs => 1 );
  89  
  90   $srch = $ldap->search( base     => "cn=People,dc=mydomain,dc=eg",
  91                          filter   => "(objectClass=person)",
  92                          callback => \&process_entry, # call for each entry
  93                          control  => [ $persist ] );
  94  
  95   die "error: ",$srch->code(),": ",$srch->error()  if ($srch->code());
  96  
  97   sub process_entry {
  98     my $message = shift;
  99     my $entry = shift;
 100     my ($control) = $message->control(LDAP_CONTROL_ENTRYCHANGE);
 101  
 102     print $control->changeType()."\t".$entry->dn()."\n";
 103   }
 104  
 105  
 106  =head1 DESCRIPTION
 107  
 108  C<Net::LDAP::Control::EntryChange> provides an interface for the creation
 109  and manipulation of objects that represent the C<EntryChangeNotification>
 110  control as described by draft-smith-psearch-ldap-01.txt.
 111  
 112  =head1 CONSTRUCTOR ARGUMENTS
 113  
 114  In addition to the constructor arguments described in
 115  L<Net::LDAP::Control> the following are provided.
 116  
 117  =over 4
 118  
 119  =item changeType
 120  
 121  An integer value telling the type of LDAP operation that the entry
 122  has undergone.
 123  It is one of the following values (which represent the LDAP
 124  operations indicated next to them):
 125  
 126  =over 4
 127  
 128  =item 1 = add
 129  
 130  =item 2 = delete
 131  
 132  =item 4 = modify
 133  
 134  =item 8 = modDN
 135  
 136  =back
 137  
 138  =item previousDN
 139  
 140  When changeType is 8 (for modDN) this parameter tells the entry's DN
 141  before the modDN operation.
 142  In all other cases this value is not defined.
 143  
 144  =item changeNumber
 145  
 146  This is the change number according to <draft-good-ldap-changelog-03.txt>
 147  assigned by a server for the change.  If a server supports an LDAP
 148  Change Log it should include this field.
 149  
 150  =back
 151  
 152  Usually you do not need to create a C<Net::LDAP::Control::EntryChange>
 153  control yourself because it is provided by the server in response to
 154  an option with the C<Net::LDAP::Control::PersistentSearch> control.
 155  
 156  =head1 METHODS
 157  
 158  As with L<Net::LDAP::Control> each constructor argument
 159  described above is also available as a method on the object which will
 160  return the current value for the attribute if called without an argument,
 161  and set a new value for the attribute if called with an argument.
 162  
 163  =head1 SEE ALSO
 164  
 165  L<Net::LDAP>,
 166  L<Net::LDAP::Control>,
 167  L<Net::LDAP::Control::PersistentSearch>
 168  
 169  =head1 AUTHOR
 170  
 171  Peter Marschall E<lt>peter@adpm.deE<gt>, based on Net::LDAP::Control::Page
 172  from Graham Barr E<lt>gbarr@pobox.comE<gt> and the preparatory work
 173  of Don Miller E<lt>donm@uidaho.eduE<gt>.
 174  
 175  Please report any bugs, or post any suggestions, to the perl-ldap
 176  mailing list E<lt>perl-ldap@perl.orgE<gt>
 177  
 178  =head1 COPYRIGHT
 179  
 180  Copyright (c) 2004 Peter Marschall. All rights reserved. This program is
 181  free software; you can redistribute it and/or modify it under the same
 182  terms as Perl itself.
 183  
 184  =cut
 185  


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