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

NAME

6       NET::LDAP::DSML -- A DSML Writer for Net::LDAP
7

SYNOPSIS

9        For a directory entry;
10
11        use Net::LDAP;
12        use Net::LDAP::DSML;
13        use IO::File;
14
15
16        my $server = "localhost";
17        my $file = "testdsml.xml";
18        my $ldap = Net::LDAP->new($server);
19
20        $ldap->bind();
21
22
23        #
24        # For file i/o
25        #
26        my $file = "testdsml.xml";
27
28        my $io = IO::File->new($file,"w") or die ("failed to open $file as filehandle.$!\n");
29
30        my $dsml = Net::LDAP::DSML->new(output => $io, pretty_print => 1 )
31             or die ("DSML object creation problem using an output file.\n");
32        #      OR
33        #
34        # For file i/o
35        #
36
37        open (IO,">$file") or die("failed to open $file.$!");
38
39        my $dsml = Net::LDAP::DSML->new(output => *IO, pretty_print => 1)
40            or die ("DSML object creation problem using an output file.\n");
41
42        #      OR
43        #
44        # For array usage.
45        # Pass a reference to an array.
46        #
47
48        my @data = ();
49        $dsml = Net::LDAP::DSML->new(output => \@data, pretty_print => 1)
50            or die ("DSML object cration problem using an output array.\n");
51
52
53         my $mesg = $ldap->search(
54                                  base     => 'o=airius.com',
55                                  scope    => 'sub',
56                                  filter   => 'ou=accounting',
57                                  callback => sub {
58                                                my ($mesg,$entry) =@_;
59                                                $dsml->write_entry($entry)
60                                                 if (ref $entry eq 'Net::LDAP::Entry');
61                                              }
62                                   );
63
64        die ("search failed with ",$mesg->code(),"\n") if $mesg->code();
65
66        For directory schema;
67
68        A file or array can be used for output, in the following example
69        only an array will be used.
70
71        my $schema = $ldap->schema();
72        my @data = ();
73        my $dsml = Net::LDAP::DSML->new(output => \@data, pretty_print => 1 )
74             or die ("DSML object creation problem using an output array.\n");
75
76        $dsml->write_schema($schema);
77
78        print "Finished printing DSML\n";
79

DESCRIPTION

81       Directory Service Markup Language (DSML) is the XML standard for
82       representing directory service information in XML.
83
84       At the moment this module only writes DSML entry and schema entities.
85       Reading DSML entities is a future project.
86
87       Eventually this module will be a full level 2 consumer and producer
88       enabling you to give you full DSML conformance.  Currently this module
89       has the ability to be a level 2 producer.  The user must understand the
90       his/her directory server will determine the consumer and producer level
91       they can achieve.
92
93       To determine conformance, it is useful to divide DSML documents into
94       four types:
95
96         1.Documents containing no directory schema nor any references to
97           an external schema.
98         2.Documents containing no directory schema but containing at
99           least one reference to an external schema.
100         3.Documents containing only a directory schema.
101         4.Documents containing both a directory schema and entries.
102
103       A producer of DSML must be able to produce documents of type 1.  A
104       producer of DSML may, in addition, be able to produce documents of
105       types 2 thru 4.
106
107       A producer that can produce documents of type 1 is said to be a level 1
108       producer. A producer than can produce documents of all four types is
109       said to be a level 2 producer.
110

CALLBACKS

112       The module uses callbacks to improve performance (at least the
113       appearance of improving performance ;) and to reduce the amount of
114       memory required to parse large DSML files. Every time a single entry or
115       schema is processed we pass the Net::LDAP object (either an Entry or
116       Schema object) to the callback routine.
117

CONSTRUCTOR

119       new ()
120           Creates a new Net::LDAP::DSML object.  There are 2 options to this
121           method.
122
123           "output" is a reference to either a file handle that has already
124           been opened or to an array.
125
126           "pretty_print" is an option to print a new line at the end of each
127           element sequence.  It makes the reading of the XML output easier
128           for a human.
129
130           Example
131
132             my $dsml = Net::LDAP::DSML->new();
133             Prints xml data to standard out.
134
135             my $dsml = Net::LDAP::DSML->new(output => \@array);
136             my $dsml = Net::LDAP::DSML->new(output => *FILE);
137             Prints xml data to a file or array.
138
139             my $dsml = Net::LDAP::DSML->new(output => \@array, pretty_print => 1);
140             my $dsml = Net::LDAP::DSML->new(output => *FILE, pretty_print => 1);
141             Prints xml data to a file or array in pretty print style.
142

METHODS

144       start_dsml ()
145           Start a DSML file.
146
147       end_dsml ()
148           End a DSML file.
149
150       write_entry ( ENTRY )
151           Entry is a Net::LDAP::Entry object. The write method will parse the
152           LDAP data in the Entry object and put it into DSML XML format.
153
154           Example
155
156             my $entry = $mesg->entry();
157             $dsml->write_entry($entry);
158
159       write_schema ( SCHEMA )
160           Schema is a Net::LDAP::Schema object. The write_schema method will
161           parse the LDAP data in the Schema object and put it into DSML XML
162           format.
163
164           Example
165
166             my $schema = $ldap->schema();
167             $dsml->write_schema($schema);
168

AUTHOR

170       Graham Barr   gbarr@pobox.com
171

SEE ALSO

173       Net::LDAP, XML::SAX::Base
174
176       Copyright (c) 2002-2006 Graham Barr. All rights reserved. This program
177       is free software; you can redistribute it and/or modify it under the
178       same terms as Perl itself.
179
180
181
182perl v5.12.0                      2010-03-12                Net::LDAP::DSML(3)
Impressum