On 9 Apr 2004, at 20:32, Don Miller wrote:
Thanks Graham, that got it working. Here is the code just in case someone else is trying to accomplish this. I have only run this against our eDirectory installation.

Great.


If you, or someone else, wants to bundle all the control/ASN code below into Net::LDAP::Control::PersistentSearch and Net::LDAP::Control::EntryChange using a similar approach/API to the existing modules, then I would be more than happy to add them.

Graham.


use Net::LDAP;
use Net::LDAP::Control;
use Convert::ASN1;
use Net::LDAP::Constant qw(LDAP_CONTROL_PERSISTENTSEARCH LDAP_CONTROL_ENTRYCHANGE);


my $ldap = Net::LDAP->new(<ldap server>, version => 3) or die "$@";
$ldap->bind(<dn>,password => <password>);

my $asn = Convert::ASN1->new;
$asn->prepare(<<EOASN) or die;
  PersistentSearch ::= SEQUENCE {
    changeTypes INTEGER,
    changesOnly BOOLEAN,
    returnECs BOOLEAN
  }

  LDAPString ::= OCTET STRING -- UTF8String ??
  LDAPDN ::= LDAPString

  EntryChangeNotification ::= SEQUENCE {
    changeType ENUMERATED {
      add         (1),
      delete      (2),
      modify      (4),
      modDN       (8)
    }
    previousDN   LDAPDN OPTIONAL,     -- modifyDN ops. only
    changeNumber INTEGER OPTIONAL     -- if supported
  }
EOASN

my $params = $asn->find('PersistentSearch')->encode(
  changeTypes => 15,
  changesOnly => 1,
  returnECs => 1
);

my $persistctl = Net::LDAP::Control->new(
  critical => true,
  type => LDAP_CONTROL_PERSISTENTSEARCH,
  value => $params
);

my $result = $ldap->search(
  filter => '(objectclass=person)',
  control => [ $persistctl ],
  callback => \&check_home
);

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

sub check_home {
my $message = shift;
my $entry = shift;
print $entry->dn,"\n";
my ($control) = $message->control(LDAP_CONTROL_ENTRYCHANGE);
my $changeType = $asn->find('EntryChangeNotification')->decode($control->value)- >{changeType};
print "$changeType\n";
}


----- Original Message -----
From: Graham Barr <[EMAIL PROTECTED]>
Date: Wednesday, April 7, 2004 9:10 am
Subject: Re: LDAP_CONTROL_ENTRYCHANGE examples against eDirectory

On 7 Apr 2004, at 11:18, Graham Barr wrote:
On 7 Apr 2004, at 11:17, Graham Barr wrote:
[NOTE to self: don't start to answer an email first thing in
the
morning]

2nd note to self. Remember to add attachments :-)


Graham.
<controls.patch>

Actually that one is not quite right. Try this one.







Reply via email to