I'm writing a perl program to read, write, add, update and delete entries in LDAP server. What I got so far is write, add, update, delete using LDIF and read that returns entries as DSML.
Now to my question - is it possible to have write, add, update, delete return DSML? Code examples would be greatly appreciated.
My search looks like this and it works like a charm,
my $dsml = Net::LDAP::DSML->new(output => $oio, pretty_print => 1 )
or die ("DSML object creation problem using an output file.\n");
$dsml->start_dsml();
$ldap->search(
base => "applicationName=HSS_ESM,nodeName=jambala",
scope => "sub",
filter => $intext,
attrs => ['*'],
callback => sub {
my ($mesg,$entry) =@_;
$dsml->write_entry($entry)
if (ref $entry eq 'Net::LDAP::Entry');
}
);
$dsml->end_dsml();
My write, add, update, delete looks like this and I would like it to return DSML on either success or error,
# Create LDIF
my $ldif = Net::LDAP::LDIF->new($fh, "r", onerror => 'undef' );
# Loop over the entries in LDIF
while ( not $ldif->eof ( ) ) {
my $entry = $ldif->read_entry( );
if ( $ldif->error ( ) ) {
# handle error
} else {
# do stuff
my $res = $entry->update($ldap);
if ($res->code != 0) {
# handle error
}
}
}
$ldif->done ( );
Thank you.