{
    "mode": "perldoc",
    "parameter": "Net::LDAP::DSML",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ALDAP%3A%3ADSML/json",
    "generated": "2026-07-05T13:43:38Z",
    "synopsis": "For a directory entry;\nuse Net::LDAP;\nuse Net::LDAP::DSML;\nuse IO::File;\nmy $server = \"localhost\";\nmy $file = \"testdsml.xml\";\nmy $ldap = Net::LDAP->new($server);\n$ldap->bind();\n#\n# For file i/o\n#\nmy $file = \"testdsml.xml\";\nmy $io = IO::File->new($file,\"w\")\nor die (\"failed to open $file as filehandle.$!\\n\");\nmy $dsml = Net::LDAP::DSML->new(output => $io, prettyprint => 1 )\nor die (\"DSML object creation problem using an output file.\\n\");\n#      OR\n#\n# For file i/o\n#\nopen (IO,\">$file\") or die(\"failed to open $file.$!\");\nmy $dsml = Net::LDAP::DSML->new(output => *IO, prettyprint => 1)\nor die (\"DSML object creation problem using an output file.\\n\");\n#      OR\n#\n# For array usage.\n# Pass a reference to an array.\n#\nmy @data = ();\n$dsml = Net::LDAP::DSML->new(output => \\@data, prettyprint => 1)\nor die (\"DSML object creation problem using an output array.\\n\");\nmy $mesg = $ldap->search(\nbase     => 'o=airius.com',\nscope    => 'sub',\nfilter   => 'ou=accounting',\ncallback => sub {\nmy ($mesg,$entry) =@;\n$dsml->writeentry($entry)\nif (ref $entry eq 'Net::LDAP::Entry');\n}\n);\ndie (\"search failed with \",$mesg->code(),\"\\n\")  if $mesg->code();\nFor directory schema;\nA file or array can be used for output, in the following example\nonly an array will be used.\nmy $schema = $ldap->schema();\nmy @data = ();\nmy $dsml = Net::LDAP::DSML->new(output => \\@data, prettyprint => 1 )\nor die (\"DSML object creation problem using an output array.\\n\");\n$dsml->writeschema($schema);\nprint \"Finished printing DSML\\n\";",
    "sections": {
        "NAME": {
            "content": "Net::LDAP::DSML -- A DSML Writer for Net::LDAP\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "For a directory entry;\n\nuse Net::LDAP;\nuse Net::LDAP::DSML;\nuse IO::File;\n\n\nmy $server = \"localhost\";\nmy $file = \"testdsml.xml\";\nmy $ldap = Net::LDAP->new($server);\n\n$ldap->bind();\n\n\n#\n# For file i/o\n#\nmy $file = \"testdsml.xml\";\n\nmy $io = IO::File->new($file,\"w\")\nor die (\"failed to open $file as filehandle.$!\\n\");\n\nmy $dsml = Net::LDAP::DSML->new(output => $io, prettyprint => 1 )\nor die (\"DSML object creation problem using an output file.\\n\");\n#      OR\n#\n# For file i/o\n#\n\nopen (IO,\">$file\") or die(\"failed to open $file.$!\");\n\nmy $dsml = Net::LDAP::DSML->new(output => *IO, prettyprint => 1)\nor die (\"DSML object creation problem using an output file.\\n\");\n\n#      OR\n#\n# For array usage.\n# Pass a reference to an array.\n#\n\nmy @data = ();\n$dsml = Net::LDAP::DSML->new(output => \\@data, prettyprint => 1)\nor die (\"DSML object creation problem using an output array.\\n\");\n\n\nmy $mesg = $ldap->search(\nbase     => 'o=airius.com',\nscope    => 'sub',\nfilter   => 'ou=accounting',\ncallback => sub {\nmy ($mesg,$entry) =@;\n$dsml->writeentry($entry)\nif (ref $entry eq 'Net::LDAP::Entry');\n}\n);\n\ndie (\"search failed with \",$mesg->code(),\"\\n\")  if $mesg->code();\n\nFor directory schema;\n\nA file or array can be used for output, in the following example\nonly an array will be used.\n\nmy $schema = $ldap->schema();\nmy @data = ();\nmy $dsml = Net::LDAP::DSML->new(output => \\@data, prettyprint => 1 )\nor die (\"DSML object creation problem using an output array.\\n\");\n\n$dsml->writeschema($schema);\n\nprint \"Finished printing DSML\\n\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Directory Service Markup Language (DSML) is the XML standard for representing directory service\ninformation in XML.\n\nAt the moment this module only writes DSML entry and schema entities. Reading DSML entities is a\nfuture project.\n\nEventually this module will be a full level 2 consumer and producer enabling you to give you\nfull DSML conformance. Currently this module has the ability to be a level 2 producer. The user\nmust understand the his/her directory server will determine the consumer and producer level they\ncan achieve.\n\nTo determine conformance, it is useful to divide DSML documents into four types:\n\n1.Documents containing no directory schema nor any references to\nan external schema.\n2.Documents containing no directory schema but containing at\nleast one reference to an external schema.\n3.Documents containing only a directory schema.\n4.Documents containing both a directory schema and entries.\n\nA producer of DSML must be able to produce documents of type 1. A producer of DSML may, in\naddition, be able to produce documents of types 2 through 4.\n\nA producer that can produce documents of type 1 is said to be a level 1 producer. A producer\nthan can produce documents of all four types is said to be a level 2 producer.\n",
            "subsections": []
        },
        "CALLBACKS": {
            "content": "The module uses callbacks to improve performance (at least the appearance of improving\nperformance ;) and to reduce the amount of memory required to parse large DSML files. Every time\na single entry or schema is processed we pass the Net::LDAP object (either an Entry or Schema\nobject) to the callback routine.\n",
            "subsections": []
        },
        "CONSTRUCTOR": {
            "content": "new ()\nCreates a new Net::LDAP::DSML object. There are 2 options to this method.\n\n\"output\" is a reference to either a file handle that has already been opened or to an array.\n\n\"prettyprint\" is an option to print a new line at the end of each element sequence. It\nmakes the reading of the XML output easier for a human.\n\nExample\n\nmy $dsml = Net::LDAP::DSML->new();\nPrints xml data to standard out.\n\nmy $dsml = Net::LDAP::DSML->new(output => \\@array);\nmy $dsml = Net::LDAP::DSML->new(output => *FILE);\nPrints xml data to a file or array.\n\nmy $dsml = Net::LDAP::DSML->new(output => \\@array, prettyprint => 1);\nmy $dsml = Net::LDAP::DSML->new(output => *FILE, prettyprint => 1);\nPrints xml data to a file or array in pretty print style.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "startdsml ()\nStart a DSML file.\n\nenddsml ()\nEnd a DSML file.\n\nwriteentry ( ENTRY )\nEntry is a Net::LDAP::Entry object. The write method will parse the LDAP data in the Entry\nobject and put it into DSML XML format.\n\nExample\n\nmy $entry = $mesg->entry();\n$dsml->writeentry($entry);\n\nwriteschema ( SCHEMA )\nSchema is a Net::LDAP::Schema object. The writeschema method will parse the LDAP data in\nthe Schema object and put it into DSML XML format.\n\nExample\n\nmy $schema = $ldap->schema();\n$dsml->writeschema($schema);\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Graham Barr gbarr@pobox.com\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Net::LDAP, XML::SAX::Base\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 2002-2006 Graham Barr. All rights reserved. This program is free software; you can\nredistribute it and/or modify it under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "Net::LDAP::DSML -- A DSML Writer for Net::LDAP",
    "flags": [],
    "examples": [],
    "see_also": []
}