NAME
Net::LDAP::LDIF - LDIF reading and writing
SYNOPSIS
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 ( );
DESCRIPTION
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.
CONSTRUCTOR
- new ( FILE )
-
Open the file read-only.
FILE
may be the name of a file or an already open filehandle. IfFILE
begins or ends with a|
thenFILE
will be passed directly toopen
. - new ( FILE, MODE, OPTIONS )
-
Open the file with the given
MODE
, eg "w" or "a".FILE
may be the name of a file or an already open filehandle. IfFILE
begins or ends with a|
thenFILE
will be passed directly toopen
. - onerror => 'die' | 'warn' | undef
-
Specify what happens when an error is detected.
METHODS
- read_entry ( )
-
Read one entry from the file and return it as a
Net::LDAP::Entry
object. - eof ( )
-
Returns true when the end of the file is reached.
- write_entry ( ENTRIES )
-
Write the entries to the LDIF file.
- done ( )
-
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.
- error ( )
-
Returns error message if error was found.
- error_lines ( )
-
Returns lines that resulted in error.
- current_entry ( )
-
Returns the current
Net::LDAP::Entry
object. - current_lines ( )
-
Returns the lines that generated the current
Net::LDAP::Entry
object. - next_lines ( )
-
Returns the lines that will generate the next
Net::LDAP::Entry
object.
AUTHOR
Graham Barr <gbarr@pobox.com>.
Please report any bugs, or post any suggestions, to the perl-ldap mailing list <perl-ldap@perl.org>.
COPYRIGHT
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.