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

DESCRIPTION

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

CALLBACKS

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

CONSTRUCTOR

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

METHODS

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

AUTHOR

167       Graham Barr   gbarr@pobox.com
168

SEE ALSO

170       Net::LDAP, XML::SAX::Base
171
173       Copyright (c) 2002-2006 Graham Barr. All rights reserved. This program
174       is free software; you can redistribute it and/or modify it under the
175       same terms as Perl itself.
176
177
178
179perl v5.8.8                       2007-02-10                Net::LDAP::DSML(3)
Impressum