Hello,

I can't get the persistent search controls to work, hope someone in this
list could help me.
The LDAP server is OpenLDAP with Sync Overlay enabled.

The program is pasted below (it's 90% based on the example from CPAN)

#!/usr/bin/perl
use strict;

use Net::LDAP;
use Net::LDAP::Control::PersistentSearch;
use Net::LDAP::Constant qw(LDAP_CONTROL_ENTRYCHANGE);

my $ldap = Net::LDAP->new( 'ldap.server.addess' ) or die "$@";

my $result = $ldap->bind ( "cn=ldap.user",
                       password => "ldap.user.pass",
                       version => 3 );

my $persist = Net::LDAP::Control::PersistentSearch->new(
                                                      changeTypes => 15,
                                                      changesOnly => 1,
                                                      returnECs => 1
                                                    );


$result = $ldap->search( base   => "dc=search,dc=base",
                         filter => "(uid=*)",
                         control  => [$persist],
                         callback => \&process_entry
                       );

if ($result->code) {
        die "error: ",$result->code(),": ",$result->error();
}

my $true =1;
while ($true) {
sleep 1;
}

$result = $ldap->unbind;

sub process_entry {
        my $result = shift;
        my $entry = shift;
        my $control = $result->control(LDAP_CONTROL_ENTRYCHANGE);
        if ($entry) {
                print $entry->dn()."\n" if $entry;
        }
}

When I run the program, I get a list of DN's of the objects right away
(despite the changesOnly => 1 specified). Is this normal ?
When I change an object in LDAP I get no output.
What is wrong, is there anything I'm missing ?

Thanks in advance.

Reply via email to