For me there are 3 solutions to dump the results of an op search :
SOL 1
@entries = $mesg->entries;
foreach $entry (@entries) {
print "dn: " . $entry->dn() . "\n";
@attrs = $entry->attributes();
foreach $attr (@attrs) {
printf("\t%s: %s\n", $attr, $entry->get_value($attr));
}
}
SOL 2
foreach $entry ($mesg->entries) { $entry->dump; }
SOL 3
Net::LDAP::LDIF->new( \*STDOUT,"w" )->write( $mesg->entries );
Regards,
-------------------------------------------------
Alexandre
-------------------------------------------------
-----Message d'origine-----
De : Kazim [mailto:[EMAIL PROTECTED]
Envoyé : mardi 1 août 2006 21:22
À : [email protected]; [EMAIL PROTECTED]
Objet : write_entry not working?
I have a "dumpuser" script that would dump an LDAP user entry.
Recently, we've added some new data which is binary and as a result,
sometimes my shell crashes when I try to dump a user.
I may not be taking the right approach to this, but I decided after
reading the docs that the right thing to do is use LDAP::LDIF to
generate a customized printout to a file, then print the file contents.
If there's a better way, please let me know.
So I ran the modified script but I get this error:
Can't locate object method "write_entry" via package "Net::LDAP::LDIF"
Here's most of the full code:
use ldaputils #my ldap management utility
use Net::LDAP::LDIF;
my $user = "rglasser";
my $file = "./foo";
my $ldap = getldap(); # runs ldap open routine
my $mesg = $ldap->search ( ... );
# parameters include passing the
# username (search routine is known to
# work from previous version)
my $ldif = Net::LDAP::LDIF->new($file, "w", onerror => 'die');
foreach my $entry($mesg->all_entries) {
$ldif->write_entry($entry);
}
$ldif->done();
As I said before, it generates a failure on the line with write_entry.
I checked the $ldif handle and it does correctly contain a
Net::LDAP::LDIF object.
Can anyone shed some light on this matter?