There is a Content Synchronization control in ldap that I am trying to
use http://www.ietf.org/internet-drafts/draft-zeilenga-ldup-sync-06.txt
For those unfamiliar it is used with openldap's syncrepl replication
service.
Essentially I want a perl client to be able to connect in
"refreshAndPersist" mode to the server passing the optional session
cookie and recieve changes that are made to the server. Once it recieves
them it'll fork or something and work on the changes.
Here is a code snippet that encodes the value for the control (SEE RFC):
use Net::LDAP;
use Net::LDAP::Control::PersistentSearch;
use Convert::ASN1;
$asn = new Convert::ASN1;
$asn->prepare(q<
SEQUENCE {
mode ENUMERATED,
cookie OCTET STRING OPTIONAL,
reloadHint BOOLEAN
}
>) || die;
$buf = $asn->encode(
mode => 3, # (refreshAndPersist)
cookie => undef,
reloadHint => false
) or die;
Here is another that actually creates the control and connects to ldap.
$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=Manager,dc=directory,dc=company,dc=com',
password => '**secretpwd**'
);
$s = $ldap->search( base => 'dc=directory,dc=company,dc=com',
scope => 'sub',
filter => '(objectclass=*)',
attrs => [ '*' ],
control => [ $ctrl ]
);
When I print out $s->error() I get "control unavailable in context"
which is error code 12. One would think that my server doesn't support
the control I'm trying to use but if I say modify the mode from the asn
encoding part to 5 (which is not valid) $s->error() becomes "Sync
control : unknown update mode" and the error code is 2.
What am I doing wrong. I thought I was encoding the asn improperly or
something but when I tested the mode change it would appear that the
server can at least parse out the mode properly so why not the other
values? Is that the problem at all? What is this context the server is
complaining about the control not being available in? Search context?
That's the only function that this control can be used in... I'm
thoroughly confused any help will be much appreciated.
Lee Jensen