Leser: 12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use Net::LDAP;
use Net::LDAP::Control::SyncRequest;
use Net::LDAP::Constant qw(
LDAP_SYNC_REFRESH_ONLY
LDAP_SYNC_REFRESH_AND_PERSIST
LDAP_SUCCESS );
$ldap = Net::LDAP->new( "localhost" );
$ldap->bind ( "cn=replicator,o=avci,c=de",
password => 'xxx' );
$req = Net::LDAP::Control::SyncRequest->new( mode => LDAP_SYNC_REFRESH_ONLY );
my $mesg = $ldap->search(base=> 'o=avci,c=de',
scope => 'sub',
control => [ $req ],
callback => \&searchCallback, # call for each entry
filter => "(objectClass=*)",
attrs => [ '*']);
sub searchCallback {
my $message = shift;
my $entry = shift;
my @controls = $message->control;
if($controls[0]->isa('Net::LDAP::Control::SyncState')) {
print "Received Sync State Control\n";
print $entry->dn()."\n";
print 'State: '.$controls[0]->state."\n".', entryUUID: '.$controls[0]->entryUUID.', cookie: '.$controls[0]->cookie;
}
elsif($controls[0]->isa('Net::LDAP::Control::SyncDone')) {
print "Received Sync Done Control\n";
print 'Cookie: '.$controls[0]->cookie.', refreshDeletes: '.$controls[0]->refreshDeletes;
}
}
1
2
3
if($controls[0] and $controls[0]->isa('Net::LDAP::Control::SyncState')) {
print "Received Sync State Control\n"; ...}
$req = Net::LDAP::Control::SyncRequest->new( mode => LDAP_SYNC_REFRESH_ONLY );