"Fossies" - the Fresh Open Source Software Archive

Member "perl-ldap-0.66/lib/Net/LDAP/Control/EntryChange.pm" (8 Apr 2015, 4650 Bytes) of package /linux/privat/perl-ldap-0.66.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "EntryChange.pm" see the Fossies "Dox" file reference documentation.

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