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

content sync control with perl search



I've been trying for a day or two now to figure out how to use a
refreshAndPersist search in a perl client. I've made some progress but
feel I'm missing something that perhaps someone on this list could
clarify... I used the following RFC as a guide to building the control
value.
http://www.ietf.org/internet-drafts/draft-zeilenga-ldup-sync-06.txt

I'll post my test code below:

use Net::LDAP;
use Net::LDAP::Control::PersistentSearch;
use Convert::ASN1;

$asn = new Convert::ASN1;
$asn->prepare(q<
        SEQUENCE {
          mode INTEGER,
          cookie     OCTET STRING OPTIONAL,
          reloadHint BOOLEAN
      }
>) || die;
$buf = $asn->encode(
    mode => 1,
    cookie => undef,
    reloadHint => true
) or die;

$ctrl = Net::LDAP::Control->new(
        type => '1.3.6.1.4.1.4203.1.9.1.1',
        value => $buf,
        critical => 1
);

$ldap = Net::LDAP->new('critter');

$ret = $ldap->bind('cn=slave_search,dc=directory,dc=sento,dc=com',
                    password => 'M@iLy!!l3s3cr3t'
);

print $ret->error(), "\n";

$s = $ldap->search( base => 'dc=directory,dc=sento,dc=com',
                scope => 'sub',
                filter => '(objectclass=*)',
                attrs => [ '*' ],
                control => [ $ctrl ]
);

print $s->error(), "\n";
print $s->count(),"\n";
print $s->control(),"\n";

Success                               (bind)
control unavailable in context        (search)
0                                     (search count)
                                      (search control print)


If I change the mode to say 5 the server fails with the error:
Sync control : unknown update mode
As rightly it should...

So I figure the ASN1 encoding is working alright. I can't for the life
of me figure out what the problem is. I have master slave replication
set up using syncrepl so I know that the refreshAndPersist controls are
compiled in and working.

Any help would be very much appreciated.

Lee