1Net::LDAP::LDIF(3)    User Contributed Perl Documentation   Net::LDAP::LDIF(3)
2
3
4

NAME

6       Net::LDAP::LDIF - LDIF reading and writing
7

SYNOPSIS

9        use Net::LDAP::LDIF;
10
11        $ldif = Net::LDAP::LDIF->new( "file.ldif", "r", onerror => 'undef' );
12        while( not $ldif->eof ( ) ) {
13          $entry = $ldif->read_entry ( );
14          if ( $ldif->error ( ) ) {
15            print "Error msg: ", $ldif->error ( ), "\n";
16            print "Error lines:\n", $ldif->error_lines ( ), "\n";
17          } else {
18            # do stuff
19          }
20        }
21        $ldif->done ( );
22

DESCRIPTION

24       Net::LDAP::LDIF provides a means to convert between Net::LDAP::Entry
25       objects and LDAP entries represented in LDIF format files. Reading and
26       writing are supported and may manipulate single entries or lists of
27       entries.
28
29       As when reading an entire file into memory with perl normally, take
30       into account the possibility of memory use when loading an LDIF file in
31       one go.
32

CONSTRUCTOR

34       new ( FILE )
35           Open the file read-only. "FILE" may be the name of a file or an
36           already open filehandle. If "FILE" begins or ends with a "⎪" then
37           "FILE" will be passed directly to "open".
38
39       new ( FILE, MODE, OPTIONS )
40           Open the file with the given "MODE", eg "w" or "a". "FILE" may be
41           the name of a file or an already open filehandle. If "FILE" begins
42           or ends with a "⎪" then "FILE" will be passed directly to "open".
43
44           encode => 'none' ⎪ 'canonical' ⎪ 'base64'
45               Some DN values in LDIF cannot be written verbatim and have to
46               be encoded in some way:
47
48               'none'
49                   The default.
50
51               'canonical'
52                   See "canonical_dn" in Net::LDAP::Util.
53
54               'base64'
55                   Use base64.
56
57           onerror => 'die' ⎪ 'warn' ⎪ undef
58               Specify what happens when an error is detected.
59
60               'die'
61                   "Net::LDAP::LDIF" will croak with an appropriate message.
62
63               'warn'
64                   "Net::LDAP::LDIF" will warn with an appropriate message.
65
66               undef
67                   "Net::LDAP::LDIF" will warn with an appropriate message if
68                   "-w" is in effect.  The method that was called will return
69                   "undef".
70
71           change => 1
72               Write entry changes to the LDIF file instead of the entries
73               itself.  I.e. write LDAP operations acting on the entries to
74               the file instead of the entries contents.
75
76           lowercase => 1
77               Convert attribute names to lowercase when writing.
78
79           sort => 1
80               Sort attribute names when writing entries according to the
81               rule: objectclass first then all other attributes alphabeti‐
82               cally sorted
83
84           version => '1'
85               Set the LDIF version to write to the resulting LDIF file.
86
87               According to RFC 2849 currently the only legal value for this
88               option is 1.
89
90               When this option is set Net::LDAP::LDIF tries to adhere more
91               strictly to the LDIF specification in RFC2489 in a few places.
92
93               The default is undef meaning no version information is written
94               to the LDIF file.
95
96           wrap => 78
97               Number of columns where output line wrapping shall occur.
98
99               Default is 78. Setting it to 40 or lower inhibits wrapping.
100
101           raw => REGEX
102               Use REGEX to denote the names of attributes that are to be con‐
103               sidered binary in search results.
104
105               When running on Perl 5.8 and this option is given Net::LDAP
106               converts all values of attributes not matching this REGEX into
107               Perl UTF-8 strings so that the regular Perl operators (pattern
108               matching, ...) can operate as one expects even on strings with
109               international characters.
110
111               If this option is not given or the version of Perl Net::LDAP is
112               running on is too old strings are encodeed the same as in ear‐
113               lier versions of perl-ldap.
114
115               Example: raw => qr/(?i:^jpegPhoto⎪;binary)/
116

METHODS

118       read_entry ( )
119           Read one entry from the file and return it as a "Net::LDAP::Entry"
120           object.
121
122       eof ( )
123           Returns true when the end of the file is reached.
124
125       write_entry ( ENTRIES )
126           Write the entries to the LDIF file.
127
128       write_version ( )
129           If the object's version is defined, this method allows to
130           explicitely write the version before an entry is written.
131
132           If  not called explicitely, it gets called automatically when writ‐
133           ing the first entry.
134
135       version ( [ VERSION ] )
136           If called without arguments it returns the version of the LDIF file
137           or undef if no version has been set.  If called with an argument it
138           sets the LDIF version to VERSION.
139
140           According to RFC 2849 currently the only legal value for VERSION is
141           1.
142
143       handle ( )
144           Returns the file handle the "Net::LDAP::LDIF" object reads fromi or
145           writes to.
146
147       done ( )
148           This method signals that the LDIF object is no longer needed. If a
149           file was opened automatically when the object was created it will
150           be closed. This method is called automatically via DESTROY when the
151           object goes out of scope.
152
153       error ( )
154           Returns error message if error was found.
155
156       error_lines ( )
157           Returns lines that resulted in error.
158
159       current_entry ( )
160           Returns the current "Net::LDAP::Entry" object.
161
162       current_lines ( )
163           Returns the lines that generated the current "Net::LDAP::Entry"
164           object.
165
166       next_lines ( )
167           Returns the lines that will generate the next "Net::LDAP::Entry"
168           object.
169

AUTHOR

171       Graham Barr <gbarr@pobox.com>.
172
173       Please report any bugs, or post any suggestions, to the perl-ldap mail‐
174       ing list <perl-ldap@perl.org>.
175
177       Copyright (c) 1997-2004 Graham Barr. All rights reserved. This program
178       is free software; you can redistribute it and/or modify it under the
179       same terms as Perl itself.
180
181
182
183perl v5.8.8                       2007-02-10                Net::LDAP::LDIF(3)
Impressum