Net::LDAP::LDIF - LDIF reading and writing
use Net::LDAP::LDIF; $ldif = Net::LDAP::LDIF->new( "file.ldif", "r", onerror => 'undef' ); while( not $ldif->eof ( ) ) { $entry = $ldif->read_entry ( ); if ( $ldif->error ( ) ) { print "Error msg: ", $ldif->error ( ), "\n"; print "Error lines:\n", $ldif->error_lines ( ), "\n"; } else { # do stuff } } $ldif->done ( );
Net::LDAP::LDIF provides a means to convert between Net::LDAP::Entry objects and LDAP entries represented in LDIF format files. Reading and writing are supported and may manipulate single entries or lists of entries.
As when reading an entire file into memory with perl normally, take into account the possibility of memory use when loading an LDIF file in one go.
Open the file read-only. FILE may be the name of a file or an already open filehandle. If FILE begins or ends with a | then FILE will be passed directly to open.
FILE
|
open
Open the file with the given MODE, eg "w" or "a". FILE may be the name of a file or an already open filehandle. If FILE begins or ends with a | then FILE will be passed directly to open.
MODE
Some values in LDIF cannot be written verbatim and have to be encoded in some way:
The default.
See "canonical_dn" in Net::LDAP::Util.
Use base64.
Specify what happens when an error is detected.
Net::LDAP::LDIF will croak with an appropriate message.
Net::LDAP::LDIF
Net::LDAP::LDIF will warn with an appropriate message.
Net::LDAP::LDIF will warn with an appropriate message if -w is in effect. The method that was called will return undef.
-w
undef
Read one entry from the file and return it as a Net::LDAP::Entry object.
Net::LDAP::Entry
Returns true when the end of the file is reached.
Write the entries to the LDIF file.
This method signals that the LDIF object is no longer needed. If a file was opened automatically when the object was created it will be closed. This method is called automatically via DESTROY when the object goes out of scope.
Returns error message if error was found.
Returns lines that resulted in error.
Returns the current Net::LDAP::Entry object.
Returns the lines that generated the current Net::LDAP::Entry object.
Returns the lines that will generate the next Net::LDAP::Entry object.
Graham Barr <gbarr@pobox.com>.
Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org>.
Copyright (c) 1997-2000 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Net::LDAP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::LDAP
CPAN shell
perl -MCPAN -e shell install Net::LDAP
For more information on module installation, please visit the detailed CPAN module installation guide.