[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: how to run script on event (modify/delete/add)?



thanks to everybody for soon reply

Michael Ströder <michael@stroeder.com> wrote:
> On 07/30/2018 02:32 PM, Zeus Panchenko wrote:
> Basically you have two options:
> 1. run something within slapd (back-perl or back-sock)

I'm still missing something ... what is/are the condition/s to see a
candidate object to sync?

I'm trying a sample from doc to Net::LDAP::Control::SyncRequest as well
as sample from SATOH Fumiyasu code

I modify some attribute and after that run the code:

---[ quotation start ]-------------------------------------------
...
my $req = $ldap_crud->control_sync_req; # which is wrapper for Net::LDAP::Control::SyncRequest->new( mode => LDAP_SYNC_REFRESH_AND_PERSIST, );
log_debug { np( $req ) };
my $mesg = $ldap_crud->search({ base      => $ldap_crud->{cfg}->{base}->{acc_root},
				filter    => "(objectClass=*)",
				control   => [ $req ],
				callback  => sub { # log_debug {np(@_)};
				  my $msg  = shift;;
				  my $obj  = shift;
				  my @controls = $msg->control;
				  if ( defined $obj && $obj->isa('Net::LDAP::Entry') ) {
				    log_debug { $obj->dn . ' ; ' . np(@controls)};
				    my $syncstate = undef;
				    for my $control (@controls) {
				      if ( $control->isa('Net::LDAP::Control::SyncState') ) {
					$syncstate = $control;
					log_debug {np($syncstate)};
					last;
				      }
				    }
				  }
				},
				sizelimit => 0,
				attrs     => [ '*' ] });
...
---[ quotation end   ]-------------------------------------------


but Net::LDAP::Message object returned by search, contains method
`controls' set to undef


---[ quotation start ]-------------------------------------------
2018.07.31 13:38:38 [DEBUG]: L00830 @ UMI::Controller::Root::test: Controller/Root.pm: Net::LDAP::Search  {
    Parents       Net::LDAP::Message
    public methods (12) : all_entries, as_struct, count, decode, entries, entry, first_entry, next_entry, pop_entry, references, shift_entry, sorted
    private methods (0)
    internals: {
        callback       sub { ... },
        controls       undef,
        ctrl_hash      undef,
        entries        [
            [0]   Net::LDAP::Entry,
	    ...
	    [388] Net::LDAP::Entry
	],
        errorMessage   "",
        matchedDN      "",
        mesgid         70,
        parent         Net::LDAP,
        raw            undef,
        resultCode     0
    }
}
---[ quotation end   ]-------------------------------------------


while Net::LDAP::Control::SyncRequest->new() returns valid object


---[ quotation start ]-------------------------------------------
2018.07.31 14:01:16 [DEBUG]: L00807 @ UMI::Controller::Root::test: Controller/Root.pm: Net::LDAP::Control::SyncRequest  {
    Parents       Net::LDAP::Control
    public methods (5) : cookie, init, mode, reloadHint, value
    private methods (0)
    internals: {
        asn    {
            cookie       undef,
            mode         3,
            reloadHint   0
        },
        mode   3,
        type   "1.3.6.1.4.1.4203.1.9.1.1"
    }
}
---[ quotation end   ]-------------------------------------------


though after been fed to search, control "disappears" ...

where am I wrong?

-- 
Zeus V. Panchenko				jid:zeus@im.ibs.dn.ua
IT Dpt., I.B.S. LLC					  GMT+2 (EET)

Attachment: signature.asc
Description: PGP signature