{
    "mode": "perldoc",
    "parameter": "Net::LDAP::FAQ",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Net%3A%3ALDAP%3A%3AFAQ/json",
    "generated": "2026-06-16T10:37:57Z",
    "synopsis": "perldoc Net::LDAP::FAQ",
    "sections": {
        "NAME": {
            "content": "Net::LDAP::FAQ - Frequently Asked Questions about Net::LDAP\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "perldoc Net::LDAP::FAQ\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This document serves to answer the most frequently asked questions on both the perl-ldap Mailing\nList and those sent to Graham Barr.\n\nThe latest version of this FAQ can be found at\n\nhttp://ldap.perl.org/FAQ.html\n",
            "subsections": []
        },
        "GENERAL": {
            "content": "What is perl-ldap?\nperl-ldap is the distribution name. The perl-ldap distribution contains the Net::LDAP modules.\n\nWhy another Perl LDAP implementation?\nperl-ldap's goal is to be as portable as possible. It does this by being implemented completely\nin Perl. So basically anywhere that Perl runs perl-ldap will run. This is not true for other\nimplementations which require a C compiler.\n\nWhere can I get it?\nPerl-ldap is available from CPAN. You can find the released versions at:\n\nhttp://search.cpan.org/dist/perl-ldap/\n\nIs there a web page for perl-ldap?\nYes there is at http://ldap.perl.org/\n\nIs there a mailing list?\nYes there is at perl-ldap@perl.org\n\nYou can subscribe to this list by mailing perl-ldap-subscribe@perl.org\n\nIs the mailing list archived?\nYes, at http://nntp.perl.org/group/perl.ldap\n\nArchives with messages before we switched to using perl.org can be found at\n\nhttp://marc.theaimsgroup.com/?l=perl-ldap-dev\n\nThere is also an archive of the perl-ldap mailing list at\n\nhttp://www.xray.mpe.mpg.de/mailing-lists/perl-ldap/\n\nwhich also has messages from before the move.\n\nIs there any online documentation?\nYes. perl-ldap has online documentation at\n\nhttp://ldap.perl.org/\n\nwhich will have the latest documentation available.\n\nIs there a public repository?\nYes, there is a public Git repository at\n\nhttps://github.com/perl-ldap/perl-ldap\n\nCan I get perl-ldap from the public Git repository?\nYes, anyone can pull perl-ldap from the public Git repository on GitHub.\n\nThere are several ways this can be done - see below.\n\nCPAN\nYou can download it from CPAN by following the \"Download\" link on:\n\nhttp://search.cpan.org/dist/perl-ldap/\n\nExample;\n\nhttp://search.cpan.org/CPAN/authors/id/M/MA/MARSCHAP/perl-ldap-0.54.tar.gz\n\nGit - fork on GitHub\nIf you have an account on GitHub (there's a free variant), you can easily fork the perl-ldap\nrepository on GitHub. When logged on to GitHub, navigate to the perl-ldap repository\n\nhttps://github.com/perl-ldap/perl-ldap\n\nand simply click on the \"Fork\" button near the top-right corner.\n\nGit - clone repository\nYou can download latest development version of perl-ldap from GitHub by cloning the\nrepository using the command:\n\ngit clone https://github.com/perl-ldap/perl-ldap.git\n\nThis command will create a directory named 'perl-ldap' in your current directory containing\na local clone of the repository.\n\nKeeping your local repository in sync with perl-ldap's GitHub repository is easy:\n\ncd perl-ldap\ngit pull\n\nWeb page\nMost of the time there is a URL link on the perl-ldap home page on ldap.perl.org that points\nto the latest released version of perl-ldap. Due to the fact that humans must update the web\npage to point to a new release it sometimes does not get updated as quickly as it should.\n\nWhat is Git?\nGit (see http://git-scm.com) is a distributed version control system designed to keep track of\nsource changes made by groups of developers working on the same files, allowing them to stay in\nsync with each other as each individual chooses.\n\nLDAP AND DIRECTORY TERMINOLOGY.\nIn order to help the user understand the perl-ldap module better some key LDAP terminology is\ndefined here.\n\nWhat is a directory?\nA directory is a special purpose hierarchical database that usually contains typed information\nsuch as text strings, binary data, or X.509 certificates.\n\nWhat is LDAP?\nLDAP stands for Lightweight Directory Access Protocol. The word *Protocol* is the key word in\nthe definition given in the preceding sentence, LDAP is *NOT* hardware or software. It is a\nprotocol that defines how a client and server will communicate with one another.\n\nThe Lightweight Directory Access Protocol is defined in a series of Requests For Comments,\nbetter known as RFCs. The RFCs can be found on the Internet at http://www.ietf.org/ (the master\nrepository) and many other places. There's a link to all the LDAP-related RFCs at perl-ldap's\nweb site, http://ldap.perl.org/rfc.html. Some of the more important RFC numbers are RFC 4510 -\n4519 for LDAP (previously called LDAPv3) and the historic RFC 1777 for LDAPv2.\n\nWhat is a LDAP Directory?\nIn the strictest terms of the definition there is no such thing as a LDAP directory. To be\npractical about this situation every day directory professionals refer to their directory as \" a\nLDAP directory\" because it is easy to say and it does convey the type of protocol used to\ncommunicate with their directory. Using this definition a LDAP directory is a directory whose\nserver software conforms to the Lightweight Directory Access Protocol when communicating with a\nclient.\n\nWhat is an Entry?\nThe traditional directory definition of a directory object is called an Entry. Entries are\ncomposed of attributes that contain the information to be recorded about the object.\n\n(An entry in LDAP is somewhat analogous to a record in a table in an SQL database, but don't get\ntoo hung up about this analogy!)\n\nEntries are held in an upside-down tree structure. Entries can therefore contain subordinate\nentries, and entries must have one direct superior entry.\n\nEntries with subordinate entries are called 'non-leaf' entries.\n\nEntries without subordinate entries are called 'leaf' entries.\n\nAn entry's direct superior entry is called the entry's 'parent'.\n\n'Non-leaf' entries are also said to have 'child' entries.\n\nWhat is an attribute?\nThe entry(s) in a directory are composed of attributes that contain information about the\nobject. Each attribute has a type and can contain one or more values.\n\nFor example:\n\ncn=Road Runner\n\nis an attribute with a type named \"cn\", and one value.\n\nEach attribute is described by a 'syntax' which defines what kind of information can be stored\nin the attributes values. Trying to store a value that doesn't conform to the attribute's syntax\nwill result in an error.\n\nFor example:\n\njpegPhoto=unknown\n\nis not permitted by the directory, because jpegPhotos may only contain JPEG-formatted images.\n\nMost syntaxes used in LDAP however describe text strings rather than binary objects (like JPEGs\nor certificates.)\n\nIn LDAPv3 most of these syntaxes support Unicode encoded using UTF-8. Because the Net::LDAP\nmodules do not change the strings that you pass in as attribute values (they get sent to the\nLDAP server as-is) to use accented characters you simply need to encode your strings in UTF-8.\nThere are modules on CPAN that will help you here.\n\nNote that LDAPv2 servers used something called T.61 instead of Unicode and UTF-8. Most servers\ndo not implement T.61 correctly, and it is recommended that you use LDAPv3 instead.\n\nAttributes may also be searched. The algorithms used to perform different kinds of searches are\ndescribed by the attribute's 'matching rules'. Some matching rules are case-sensitive and some\nare case-insensitive, for example. Sometimes matching rules aren't defined for a particular\nattribute: there's no way to search for jpegPhotos that contain a substring!\n\nYou can examine all of a server's attribute definitions by reading the schema from the server.\n\nWhat is an object class?\nAn object class is the name associated with a group of attributes that must be present in an\nentry, and the group of attributes that may also be present in an entry.\n\nObject classes may be derived (subclassed) from other object classes. For example the widely\nused 'inetOrgPerson' object class is derived from 'organizationalPerson', which is itself\nderived from 'person' which is itself derived from 'top'.\n\nEvery entry has an attribute called 'objectClass' that lists all the names of object classes\n(and their superclasses) being used with the entry.\n\nYou can examine all of a server's objectclass definitions by reading the schema from the server.\n\nWhat is a Distinguished Name (DN)?\nEvery entry in a directory has a Distinguished Name, or DN. It is a unique Entry identifier\nthroughout the complete directory. No two Entries can have the same DN within the same\ndirectory.\n\nExamples of DNs:\n\ncn=Road Runner, ou=bird, dc=cartoon, dc=com\nou=bird, dc=cartoon, dc=com\ndc=cartoon, dc=com\ndc=com\n\nWhat is a Relative Distinguished Name?\nEvery DN is made up of a sequence of Relative Distinguished Names, or RDNs. The sequences of\nRDNs are separated by commas (,). In LDAPv2 semi-colons (;) were also allowed. There can be more\nthan one identical RDN in a directory, but they must have different parent entries.\n\nTechnically, an RDN contains attribute-value assertions, or AVAs. When an AVA is written down,\nthe attribute name is separated from the attribute value with an equals (=) sign.\n\nExample of a DN:\n\ncn=Road Runner,ou=bird,dc=cartoon,dc=com\n\nRDNs of the proceeding DN:\nRDN => cn=Road Runner\nRDN => ou=bird\nRDN => dc=cartoon\nRDN => dc=com\n\nRDNs can contain multiple attributes, though this is somewhat unusual. They are called multi-AVA\nRDNs, and each AVA is separated in the RDN from the others with a plus sign (+).\n\nExample of a DN with a multi-AVA RDN:\n\ncn=Road Runner+l=Arizona,ou=bird,dc=cartoon,dc=com\n\nWhere is an entry's name held?\nEntries do not contain their DN. When you retrieve an entry from a search, the server will tell\nyou the DN of each entry.\n\nOn the other hand, entries do contain their RDN. Recall that the RDN is formed from one or more\nattribute-value assertions (AVAs); each entry must contain all the attributes and values in the\nRDN.\n\nFor example the entry:\n\ncn=Road Runner+l=Arizona,ou=bird,dc=cartoon,dc=com\n\nmust contain a 'cn' attribute containing at least the value \"Road Runner\", and an 'l' attribute\ncontaining at least the value \"Arizona\".\n\nThe attributes used in the RDN may contain additional values, but the entry still only has one\nDN.\n\nWhat is a search base?\nA search base is a Distinguished Name that is the starting point of search queries.\n\nExample of a DN:\n\ncn=Road Runner,ou=bird,dc=cartoon,dc=com\n\nPossible search base(s) for the proceeding DN:\n\nBase => cn=Road Runner,ou=bird,dc=cartoon,dc=com\nBase => ou=bird,dc=cartoon,dc=com\nBase => dc=cartoon,dc=com\nBase => dc=com\n\nSetting the search base to the lowest possible branch of the directory will speed up searches\nconsiderably.\n\nWhat is the difference between a LDAP server and a relational database?\nThe most basic difference is that a directory server is a specialized database designed to\nprovide fast searches. While a relational database is optimized for transactions (where a series\nof operations is counted as 1, thus if one of the steps fails, the RDBMS can roll-back to the\nstate it was in before you started).\n\nDirectories also typically are hierarchical in nature (RDBMS is typically flat, but you can\nimplement a hierarchy using tables and queries), networkable, distributed and replicated.\n\nLDAP provides an open-standard to a directory service.\n\nTypically we use LDAP for email directories (all popular email clients provide an LDAP client\nnow) and authorization services (authentication and access control).\n\nYou could use a RDBMS for these types of queries but there's no set standard, in particular over\nTCP/IP to connect to databases over the network. There's language specific protocols (like\nPerl's DBI and Java's JDBC) that hide this problem behind an API abstraction, but that's not a\nreplacement for a standard access protocol.\n\nLDAP is starting to be used on roles traditionally played by RDBMS in terms of general data\nmanagement because it's easier to setup a LDAP server (once you understand the basic\nnomenclature) and you don't need a DBA to write your queries and more importantly all LDAP\nservers speak the same essential protocol, thus you don't have to fuss with a database driver\ntrying to connect it to the Internet. Once you have an LDAP server up and running, it's\nautomatically available over the 'net. It's possible to connect to a LDAP server from a variety\nof mechanisms, including just about every possible programming language.\n\nMore information on this topic can be found on the following URLs;\n\nhttp://www.openldap.org/faq/data/cache/378.html\n\nhttp://www.isode.com/whitepapers/ic-6055.html\n\nWhat is the difference between a ldap reference and a ldap referral?\nA referral is returned when the entire operation must be resent to another server.\n\nA continuation reference is returned when part of the operation must be resent to another\nserver.\n\nSee RFC 4511 section 4.5.3 for more details.\n\nperl-ldap INSTALLATION\nHow do I install perl-ldap?\nTo install the modules that are in the perl-ldap distribution follow the same steps that you\nwould for most other distributions found on CPAN, that is\n\n# replace 0.62 with the version you have\n\ngunzip perl-ldap-0.62.tar.gz\ntar xvf perl-ldap-0.62.tar\ncd perl-ldap-0.62\n\nperl Makefile.PL\nmake\nmake test\nmake install\n\nBut I do not have make, how can I install perl-ldap?\nWell as luck would have it the modules in perl-ldap do not do anything complex, so a simple copy\nis enough to install. First run\n\nperl -V\n\nThis will output information about the version of Perl you have installed. Near the bottom you\nwill find something like\n\n@INC:\n/usr/local/lib/perl/5.18.2\n/usr/local/share/perl/5.18.2\n/usr/lib/perl5\n/usr/share/perl5\n/usr/lib/perl/5.18\n/usr/share/perl/5.18\n/usr/local/lib/siteper\n\nThis is a list of directories that Perl searches when it is looking for a module. The directory\nyou need is the siteperl directory, but without the system architecture name, in this case it\nis \"/usr/local/lib/siteperl\". The files required can then be installed with\n\n# replace 0.62 with the version you have\n\ngunzip perl-ldap-0.62.tar.gz\ntar xvf perl-ldap-0.62.tar\ncd perl-ldap-0.62/lib\n\ncp -r * /usr/local/lib/siteperl\n\nHow can I load perl-ldap into an ActiveState Perl installation?\nThere are several ways that perl-ldap can be installed into an ActiveState Perl tree.\n\n1.  The ActiveState ppm command can be used to install perl-ldap. When a new version of\nperl-ldap is released, it takes ActiveState a period of time to get the new release into the\nActiveState ppm system.\n\n2.  If the user has nmake installed, the user can do a normal Perl module install using nmake\ninstead of make.\n\n3.  If the user does not have nmake or make, the user can install perl-ldap using the\ninstall-nomake script by issuing the following command.\n\nperl install-nomake\n\nThe install-nomake script can be used on any system that does not have make installed.\n\nWhat other modules will I need?\nperl-ldap uses other Perl modules. Some are required, but some are optional (i.e. required to\nuse certain features only).\n\nIf you are using a Linux system, many of the distributions have packages that you can install\nusing the distribution's package management tools (e.g. apt, rpm, ...).\n\nAlternatively, you may use your favorite web search engine to find the package that you need.\n\nConvert::ASN1\nThis module converts between Perl data structures and ASN.1, and is required for perl-ldap\nto work.\n\nYou can obtain the latest release from http://search.cpan.org/search?module=Convert::ASN1\n\nOpenSSL and IO::Socket::SSL\nIf you want to use encrypted connections, either via starttls or LDAPS connections, you\nwill need this module and the OpenSSL software package.\n\nYou can obtain the latest release of IO::Socket::SSL from\nhttp://search.cpan.org/search?module=IO::Socket::SSL\n\nYou can obtain the latest release of OpenSSL from http://www.openssl.org/\n\nIO::Socket::INET6\nFor connecting to LDAP servers via IPv6, IO::Socket::INET6 is required. Its presence is\ndetected at runtime, so that perl-ldap can be installed without it, and automatically gains\nIPv6 support as soon as IO::Socket::INET6 gets installed.\n\nYou can obtain the latest releases from\nhttp://search.cpan.org/search?module=IO::Socket::INET6\n\nIO::Socket::IP\nThis is an alternative to using IO::Socket::INET6. Like that module, it gets detected\nautomatically at runtime. If version 0.20 or higher is installed, is is preferred over\nIO::Socket::INET6 and IO::Socket::INET for all IP connections.\n\nYou can obtain the latest releases from http://search.cpan.org/search?module=IO::Socket::IP\n\nAuthen::SASL\nThis module is optional. You only need to install Authen::SASL if you want to use the SASL\nauthentication methods.\n\nYou can obtain the latest release from http://search.cpan.org/search?module=Authen::SASL\n\nDigest::MD5\nThis module is optional. It also requires a C compiler when installing. You only need to\ninstall Digest::MD5 if you want to use the SASL DIGEST-MD5 authentication mechanism.\n\nYou can obtain the latest release from http://search.cpan.org/search?module=Digest::MD5\n\nAs Digest::MD5 is part of the Perl core modules since Perl 5.7.3, you only need a C compiler\nif you want to install a version that is newer than the version distributed with your Perl\ninstallation.\n\nDigest::HMACMD5\nThis optional module is required only if you want to use the SASL CRAM-MD5 authentication\nmechanism.\n\nYou can obtain the latest release from http://search.cpan.org/search?module=Digest::HMACMD5\n\nGSSAPI\nThis optional module is required only if you want to use the SASL GSSAPI authentication\nmechanism (e.g. for Kerberos authentication).\n\nYou can obtain the latest release from http://search.cpan.org/search?module=GSSAPI\n\nURI::ldap, URI::ldaps, and URI::ldapi\nThese modules are optional. You only need to install them if you want to parse ldap://,\nldaps:// or ldapi:// URIs using ldapparseuri in Net::LDAP::Util. or use\nLWP::Protocol::ldap, LWP::Protocol::ldaps, or LWP::Protocol::ldapi.\n\nYou can obtain the latest releases from http://search.cpan.org/search?module=URI::ldap\nhttp://search.cpan.org/search?module=URI::ldaps\nhttp://search.cpan.org/search?module=URI::ldapi\n\nLWP::Protocol, LWP::MediaTypes, HTTP::Negotiate, and HTTP::Response\nThese optional modules are needed if you want to use perl-ldap's LWP::Protocol::ldap,\nLWP::Protocol::ldaps, or LWP::Protocol::ldapi modules.\n\nYou can obtain the latest releases from http://search.cpan.org/search?module=LWP::Protocol\nhttp://search.cpan.org/search?module=LWP::MediaTypes\nhttp://search.cpan.org/search?module=HTTP::Negotiate\nhttp://search.cpan.org/search?module=HTTP::Response\n\nJSON\nThis optional module is required for JSON-formatted output of perl-ldap's\nLWP::Protocol::ldap, LWP::Protocol::ldaps, or LWP::Protocol::ldapi modules.\n\nIf you need it, you can obtain the latest releases from\nhttp://search.cpan.org/search?module=JSON\n\nTime::Local\nThis module is optional, and only required if you want to convert between UNIX time and\ngeneralizedTime using the functions provided in Net::LDAP::Util.\n\nXML::SAX and XML::SAX::Writer\nIf you want to parse or write DSMLv1 documents with Net::LDAP::DSML to you will need these\noptional modules.\n\nYou can obtain the latest releases from http://search.cpan.org/search?module=XML::SAX\nhttp://search.cpan.org/search?module=XML::SAX::Writer\n\nResourcePool::Factory::Net::LDAP\nIf you want to use failover the ResourcePool::Factory::Net::LDAP Perl module provides\nmethods to do this.\n\nYou can obtain the latest release from\nhttp://search.cpan.org/search?module=ResourcePool::Factory::Net::LDAP\n\nUSING NET::LDAP\nHow do I connect to my server?\nThe connection to the server is created when you create a new Net::LDAP object, e.g.\n\n$ldap = Net::LDAP->new($server);\n\nNet::LDAP->new sometimes returns undef, why?\nThe constructor will return undef if there was a problem connecting to the specified server. Any\nerror message will be available in $@\n\nWhat is the proper format of the bind DN?\nThe DN used to bind to a directory is a FULLY QUALIFIED DN. The exact structure of the DN will\ndepend on what data has been stored in the server.\n\nThe following are valid examples.\n\nuid=clif,ou=People,dc=umich,dc=edu\n\ncn=directory manager,ou=admins,dc=umich,dc=edu\n\nIn some servers the following would be a valid fully qualified DN of the directory manager.\n\ncn=directory manager\n\nHow can I tell when the server returns an error, bind() always returns\ntrue?\nMost methods in Net::LDAP return a Net::LDAP::Message object, or a sub-class of that. This\nobject will hold the results from the server, including the result code.\n\nSo, for example, to determine the result of the bind operation.\n\n$mesg = $ldap->bind( $dn, password => $passwd );\n\nif ( $mesg->code ) {\n# Handle error codes here\n}\n\nHow can I set the LDAP version of a connection to my LDAP server?\nThis is done by adding the version option when connecting or binding to the LDAP server.\n\nFor example;\n\n$ldap = Net::LDAP->new( $server, version => 3 );\n\nor\n\n$mesg = $ldap->bind( $dn, password => $passwd, version => 3 );\n\nValid version numbers are 2 and 3. As of perl-ldap 0.27 the default LDAP version is 3.\n\nI did a search on my directory using the 'search' method. Where did\nthe results go?\nYour search results are stored in a 'search object'. Consider the following:\n\nuse Net::LDAP;\n\n$ldap = Net::LDAP->new('ldap.acme.com') or die \"$@\";\n$mesg = $ldap->search(\nbase   => \"o=acme.com\",\nfilter => \"uid=jsmith\",\n);\n\n$mesg is a search object. It is a reference blessed into the Net::LDAP::Search package. By\ncalling methods on this object you can obtain information about the result and also the\nindividual entries.\n\nThe first thing to check is if the search was successful. This is done with the method\n$mesg->code. This method will return the status code that the server returned. A success will\nyield a zero value, but there are other values, some of which could also be considered a\nsuccess. See Net::LDAP::Constant\n\nuse Net::LDAP::Util qw(ldaperrortext);\n\ndie ldaperrortext($mesg->code)\nif $mesg->code;\n\nThere are two ways in which you can access the entries. You can access then with an index or you\ncan treat the container like a stack and shift each entry in turn. For example\n\n# as an array\n\n# How many entries were returned from the search\nmy $max = $mesg->count;\n\nfor (my $index = 0 ; $index < $max ; $index++) {\nmy $entry = $mesg->entry($index);\n# ...\n}\n\n# or as a stack\n\nwhile (my $entry = $mesg->shiftentry) {\n# ...\n}\n\nIn each case $entry is an entry object. It is a reference blessed into the Net::LDAP::Entry\npackage. By calling methods on this object you can obtain information about the entry.\n\nFor example, to obtain the DN for the entry\n\n$dn = $entry->dn;\n\nTo obtain the attributes that a given entry has\n\n@attrs = $entry->attributes;\n\nAnd to get the list of values for a given attribute\n\n@values = $entry->get( 'sn' );\n\nAnd to get the first of the values for a given attribute\n\n$values = $entry->get( 'cn' );\n\nOne thing to remember is that attribute names are case insensitive, so 'sn', 'Sn', 'sN' and 'SN'\nare all the same.\n\nSo, if you want to print all the values for the attribute 'ou' then this is as simple as\n\nforeach ($entry->getvalue( 'ou' )) {\nprint $,\"\\n\";\n}\n\nNow if you just want to print all the values for all the attributes you can do\n\nforeach my $attr ($entry->attributes) {\nforeach my $value ($entry->getvalue($attr)) {\nprint $attr, \": \", $value, \"\\n\";\n}\n}\n\nHow do I limit the scope of a directory search?\nYou limit the scope of a directory search by setting the scope parameter of search request.\nConsider the following:\n\nuse Net::LDAP;\n\n$ldap = Net::LDAP->new('ldap.acme.com') or die \"$@\";\n$mesg = $ldap->search(\nbase   => \"o=acme.com\",\nscope  => 'sub',\nfilter => \"uid=jsmith\",\n);\n\nValues for the scope parameter are as follows.\n\nbase\nSearch only the base object.\n\none Search the entries immediately below the base object.\n\nsub\nsubtree\nSearch the whole tree below (and including) the base object. This is the default.\n\nchildren\nSearch the whole subtree below the base object, excluding the base object itself.\n\nNote: *children* scope requires LDAPv3 subordinate feature extension.\n",
            "subsections": []
        },
        "GETTING SEARCH RESULTS": {
            "content": "There are two ways of retrieving the results of a requested LDAP search; inline and by using a\ncallback subroutine.\n\nUSING THE INLINE APPROACH\nUsing the inline approach involves requesting the data and then waiting for all of the data to\nbe returned before the user starts processing the data.\n\nExample:\n\nuse Net::LDAP;\n\n$ldap = Net::LDAP->new('ldap.acme.com') or die \"$@\";\n$mesg = $ldap->search(\nbase   => \"o=acme.com\",\nscope  => 'sub',\nfilter => \"sn=smith\",\n);\n#\n# At this point the user can get the returned data as an array\n# or as a stack.\n# In this example we will use an array\n\n# How many entries were returned from the search\nmy $max = $mesg->count;\n\nfor (my $index = 0 ; $index < $max ; $index++)\n{\nmy $entry = $mesg->entry($index);\nmy $dn = $entry->dn; # Obtain DN of this entry\n\n@attrs = $entry->attributes; # Obtain attributes for this entry.\nforeach my $var (@attrs)\n{\n#get a list of values for a given attribute\n$attr = $entry->getvalue( $var, asref => 1 );\nif ( defined($attr) )\n{\nforeach my $value ( @$attr )\n{\nprint \"$var: $value\\n\";  # Print each value for the attribute.\n}\n}\n}\n}\n\nAs you can see the example is straightforward, but there is one drawback to this approach. You\nmust wait until all entries for the request search to be returned before you can process the\ndata. If there several thousand entries that match the search filter this could take quite a\nlong time period.\n\nUSING THE CALLBACK SUBROUTINE APPROACH\nUsing the callback approach involves requesting the data be sent to a callback subroutine as\neach entry arrives at the client.\n\nA callback is just a subroutine that is passed two parameters when it is called, the mesg and\nentry objects.\n\nExample:\n\nuse Net::LDAP;\n\n$ldap = Net::LDAP->new('ldap.acme.com') or die \"$@\";\n$mesg = $ldap->search(\nbase   => \"o=acme.com\",\nscope  => 'sub',\nfilter => \"sn=smith\",\ncallback => \\&callback,\n);\n#\n# At this point the user needs to check the status of the\n# ldap search.\n#\n\nif ( $mesg->code )\n{\n$errstr = $mesg->code;\nprint \"Error code:  $errstr\\n\";\n$errstr = ldaperrortext($errstr);\nprint \"$errstr\\n\";\n}\n\n\nsub callback\n{\nmy ( $mesg, $entry) = @;\n\n#\n# First you must check to see if something was returned.\n# Last execution of callback subroutine will have no\n# defined entry and mesg object\n#\nif ( !defined($entry) )\n{\nprint \"No records found matching filter $match.\\n\"\nif ($mesg->count == 0) ; # if mesg is not defined nothing will print.\nreturn;\n}\n\nmy $dn = $entry->dn; # Obtain DN of this entry\n\n@attrs = $entry->attributes; # Obtain attributes for this entry.\nforeach my $var (@attrs)\n{\n#get a list of values for a given attribute\n$attr = $entry->getvalue( $var, asref => 1 );\nif ( defined($attr) )\n{\nforeach my $value ( @$attr )\n{\nprint \"$var: $value\\n\";  # Print each value for the attribute.\n}\n}\n}\n#\n# For large search requests the following line of code\n# may be very important, it will reduce the amount of memory\n# used by the search results.\n#\n# If the user is not worried about memory usage then the line\n# of code can be omitted.\n#\n$mesg->popentry;\n\n}  # End of callback subroutine\n\nAs you can see the example is straightforward and it does not waste time waiting for all of the\nentries to be returned. However if the popentry method is not used the callback approach can\nallocate a lot of memory to the search request.\n\nUSING NET::LDAPS\nUsing an SSL network connection, how do I connect to my server?\nThis class is a subclass of Net::LDAP so all the normal Net::LDAP methods can be used with a\nNet::LDAPS object; see the documentation for Net::LDAP to find out how to query a directory\nserver using the LDAP protocol.\n\nThe connection to the server is created when you create a new Net::LDAPS object, e.g.\n\n$ldaps = Net::LDAPS->new($server,\nport => '10000',\nverify => 'require',\ncapath => '/usr/local/cacerts/',\n);\n\nStarting with version 0.28 perl-ldap also supports URIs in the new method. So, the above can\nalso be expressed as:\n\n$ldaps = Net::LDAP->new(\"ldaps://$server\",\nport => '10000',\nverify => 'require',\ncapath => '/usr/local/cacerts/',\n);\n\nThere are additional options to the new method with LDAPS URIs and the LDAPS new method and\nseveral additional methods are included in the LDAPS object class.\n\nFor further information and code examples read the LDAPS module documentation; perldoc\nNet::LDAPS\n\nUSING LDAP GROUPS.\nWhat are LDAP groups?\nLDAP groups are object classes that contain an attribute that can store multiple DN values. Two\nstandard object classes are 'groupOfNames' (which has a 'member' attribute) and\n'groupOfUniqueNames' (which has a 'uniqueMember' attribute.)\n\nAccording to the RFCs a group can be a member of another group, but some LDAP server vendors\nrestrict this flexibility by not allowing nested groups in their servers.\n\nTwo scripts for working with groups are available in the contrib directory. They are isMember.pl\nand printMembers.pl.\n",
            "subsections": [
                {
                    "name": "How do you format a filter to search for entries whose 'member'",
                    "content": "attribute has a particular value?\nAsking for (member=*) is OK - the directory uses the equality matching rule which is defined for\nthe member attribute.\n\nAsking for (member=c*) is not OK - there is no defined substring matching rule for the member\nattribute. That's because the member values are *not* strings, but distinguished names. There is\nno substring matching rule for DNs, see RFC 4519 section 2.7.\n\nWhat you have to do is get the results of (member=*) and then select the required results from\nthe returned values. You need to do this using knowledge of the string representation of DNs\ndefined in RFC 4514, which is important because the same DN can have different string\nrepresentations. So you need to perform some canonicalization if you want to be correct.\n\nUSING DSML.\nHow can I access DSML features from perl-ldap?\nDirectory Service Markup Language (DSML) is the XML standard for representing directory service\ninformation in XML.\n\nSupport for DSML is included in perl-ldap starting with version .20.\n\nAt the moment this module only reads and writes DSML entry entities. It cannot process any\nschema entities because schema entities are processed differently than elements.\n\nEventually this module will be a full level 2 consumer and producer enabling you to give you\nfull DSML conformance.\n\nThe specification for DSML is at http://www.oasis-open.org/specs/\n\nFor further information and code examples read the DSML module documentation; perldoc\nNet::LDAP::DSML\n\nUSING CONTROLS AND VIRTUAL LISTS.\nHow do I access the Control features?\nSupport for LDAP version 3 Control objects is included in perl-ldap starting with version .20.\n\nFor further information and code examples read the Control module documentation; perldoc\nNet::LDAP::Control\n\nHow do I access the Virtual List features?\nSupport for Virtual Lists is included in perl-ldap starting with version .20.\n\nFor further information and code examples read the Control module documentation; perldoc\nNet::LDAP::Control\n\nGENERAL QUESTIONS."
                },
                {
                    "name": "Are there any other code examples.",
                    "content": "Yes, there is an Examples pod file. To view the pod do the following command; perldoc\nNet::LDAP::Examples\n\nThere is user contributed software in the contrib directory that is supplied with the perl-ldap\ndistribution. This is an excellent source of information on how to use the perl-ldap module.\n\nAre there any performance issues with perl-ldap?\nIn the vast majority of use cases (one user has suggested 9 out of 10) there are no performance\nissues with perl-ldap.\n\nWhere you may wish to use perl-ldap to perform, for example, a very large number of queries\n(e.g. 10,000) in succession you may find a noticeable performance difference between perl-ldap\nand non pure-Perl modules. This is not because of perl-ldap itself but because of the pure-Perl\nConvert::ASN1 module that it depends on.\n\nYou should make up your own mind, based upon your own situation (performance requirements,\nhardware etc.) as to whether you should use perl-ldap or not. The figures quoted in this answer\nare only indicative, and will differ for different people.\n"
                },
                {
                    "name": "Can I contribute Perl scripts that use perl-ldap",
                    "content": "to the contrib section?\nAny one can submit a Perl script that uses perl-ldap for inclusion in the contrib section. The\nperl-ldap maintainers will determiner if the script will be included and will do the initial\ncheck in of the script to the Git repository at https://github.com/perl-ldap/perl-ldap.\n\nThere are a couple of requirements for consideration.\n\nYou must supply a one line description of your script to be included in the contrib README file.\n\nInside the script will be the pod documentation for the script. No auxiliary documentation will\nbe allowed. For examples of how to do this see the tklkup script currently in the contrib\nsection.\n"
                },
                {
                    "name": "Is it possible to get a complete entry, DN and attributes",
                    "content": "without specifying the attributes name?\nYes, just specify you want a list of no attributes back. The RFC says that this tells the server\nto return all readable attributes back (there may be access controls to prevent some from being\nreturned.)\n\nSo in the search method, just set (for LDAPv2):\n\nattrs => [ ]\n\nIf you are using LDAPv3, you can specify an attribute called \"*\" instead, which lets you ask for\nadditional (i.g. operational) attributes in the same search.\n\nattrs => [ \"*\" ]\n\nTo get all operational attributes in a search, some servers allow the use of the \"+\" pseudo\nattribute. So that with these servers\n\nattrs => [ \"*\", \"+\" ]\n\nwill return the most information from the server.\n\nHow do I put a JPEG photo into a entry in the directory?\nFollow the following code example, replacing the (...) with whatever is relevant to your setup.\n\nuse Net::LDAP;\nuse Net::LDAP::Util qw(ldaperrortext);\nuse CGI;\n\nlocal $/ = undef;\nmy $jpeg = <$filename>;\n\nmy $ldap = Net::LDAP->new(...);\nmy $res = $ldap->bind(...);\n$res = $ldap->modify(...,\nadd => [ 'jpegPhoto' => [ $jpeg ] ]);\n$res = $ldap->unbind();\n\nHow do I add a jpeg photo into a entry in the directory via html-forms?\nFollow the following code example, replacing the (...) with whatever is relevant to your setup.\n\nuse Net::LDAP;\nuse Net::LDAP::Util qw(ldaperrortext);\nuse CGI;\n\nmy $q = new CGI;\n\nprint $q->header;\nprint $q->starthtml(-title => 'Change JPEG photo');\n\nif ($q->param('Update')) {\nmy $filename = $q->param('jpeg');\nlocal $/ = undef;\nmy $jpeg = <$filename>;\n\nmy $ldap = Net::LDAP->new(...);\nmy $res = $ldap->bind(...);\n$res = $ldap->modify(...,\nadd => [ 'jpegPhoto' => [ $jpeg ] ]);\n$res = $ldap->unbind();\n} else {\nprint $q->startmultipartform();\nprint $q->filefield(-name => 'jpeg', -size => 50);\nprint $q->submit('Update');\nprint $q->endform();\n}\n\nprint $q->endhtml();\n\nWhat happens when you delete an attribute that does not exist?\nIt is an error to delete an attribute that doesn't exist. When you get the error back the server\nignores the entire modify operation you sent it, so you need to make sure the error doesn't\nhappen.\n\nAnother approach, if you are using LDAPv3 (note beginning with version .27 Net::LDAP uses LDAPv3\nby default) is to use a 'replace' with your attribute name and no values. In LDAPv3, this is\ndefined to always work even if that attribute doesn't exist in the entry.\n\nI.e.:\n\nmy $mesg = $ldap->modify( $entry, replace => { %qvdelarry } );\n\nBut make sure you are using LDAPv3, because that is defined to not work in LDAPv2. (A nice\nincompatibility between LDAPv2 and LDAPv3.)\n\nHow can I delete a referral from an LDAP tree?\nSince this is a proprietary feature, you will have to check your server's documentation. You\nmight find that you need to use a control. If there is a control called something like\nManageDsaIT, that's the one you should probably use. For proper operation you will need the oid\nnumber for ManageDsaIT; 2.16.840.1.113730.3.4.2 and do not specify a value for type.\n\nThe code required will look similar to the following code snippet.\n\n$mesg =  $ldap->delete(\"ref=\\\"ldap://acme/c=us,o=bricks\\\",o=clay\",\ncontrol => {type => \"2.16.840.1.113730.3.4.2\"} );\n\nHow do I add an ACI/ACL entry to a directory server with\nperl-ldap?\nACIs and ACLs are proprietary features in LDAP. The following code snippet works with a Netscape\ndirectory server. You will need the specify the correct DN (-DN-) and correct attribute(s)\n(-ATTRNAMEs-).\n\nmy $aci = '(target=\"ldap:///-DN-\")(targetattr=\"-ATTRNAMEs-\")(version 3.0;\nacl \"-ACLNAME-\"; deny(all) userdn = \"ldap:///self\";)' ;\n\n$ldap->modify($dnmodif, add => {'aci' => $aci });\n"
                },
                {
                    "name": "How do I avoid file type and data type mis-matching when loading",
                    "content": "data from a Win32 system?\nWhen loading a binary attribute with data read from a file on a Win32 system, it has been noted\nthat you should set \"binmode\" on the file before reading the file contents into the data array.\n\nAnother possible solution to this problem is to convert the binary data into a base64 encoded\nstring and then store the encoded string in the file. Then when reading the file, decode the\nbase64 encoded string back to binary and then use perl-ldap to store the data in the directory.\n\nHow do I create an account in Active Directory?\nActive Directory accounts need some AD-specific attributes (only the method we're interested in,\nno error checking):\n\n$mesg = $ldap->add( 'cn=John Doe,cn=Users,dc=your,dc=ads,dc=domain',\nattrs => [\nobjectClass => [ qw/top user/ ],\ncn => 'John Doe',\nsn => 'Doe',\ngivenName => 'John',\ndisplayName => 'John \"the one\" Doe',\nuserAccountControl => 514,      # disabled regular user\nsAMAccountName => 'JohnDoe',\nuserPrincipalName => 'JohnDoe@your.ads.domain'\n]\n);\n\nIn order to find out what other attributes can be set, interactively edit the user in the Active\nDirectory Users and Computers MCC plugin, perform an LDAP search operation to find out what\nchanged, and update your \"add\" routine accordingly.\n\nHow can I create a group in Active Directory?\nSimilar to accounts, groups need some AD-specific attributes too:\n\n$mesg = $ldap->add( 'cn=NewGroup,cn=Users,dc=your,dc=ads,dc=domain',\nattrs => [\nobjectClass => [ qw/top group/ ],\ncn => 'NewGroup',\nsAMAccountName => 'NewGroup',\ngroupType => 0x80000002         # global, security enabled group\n]\n);\n"
                },
                {
                    "name": "How do I search for disabled accounts in Active Directory",
                    "content": "The bit values in \"userAccountControl\" require the LDAPMATCHINGRULEBITAND matching rule's\nOID to be used in an extensible filter term:\n\n$mesg = $ldap->search( base   => 'cn=Users,dc=your,dc=ads,dc=domain',\nfilter => '(&(objectclass=user)' .\n(userAccountControl:1.2.840.113556.1.4.803:=2))',\nattrs  => [ '1.1' ]\n);\n"
                },
                {
                    "name": "How can I search for security groups in Active Directory",
                    "content": "With groups, the same applies to the \"groupType\" bit-field:\n\n$mesg = $ldap->search( base   => 'cn=Users,dc=your,dc=ads,dc=domain',\nfilter => '(&(objectclass=group)' .\n(groupType:1.2.840.113556.1.4.803:=2147483648))',\n# 2147483648 = 0x80000000\nattrs  => [ '1.1' ]\n);\n\nHow can I search for all members of a group in AD (including group nesting)?\nAD allows you to find all members of a specified group, the direct members plus those that are\nmember of the group via group nesting.\n\nThe trick to this is the special \"LDAPMATCHINGRULEINCHAIN\" matching rule:\n\n$mesg = $ldap->search( base   => 'cn=Users,dc=your,dc=ads,dc=domain',\nfilter => '(memberOf:1.2.840.113556.1.4.1941:=cn=Testgroup,dc=your,dc=ads,dc=domain)',\nattrs  => [ '1.1' ]\n);\n\nHow can I search for all groups one user is a member of in AD (including group nesting)?\nSimilarly you can search for all the groups one user is member of, either directly or via group\nnesting.\n\n$mesg = $ldap->search( base   => 'dc=your,dc=ads,dc=domain',\nfilter => '(member:1.2.840.113556.1.4.1941:=cn=TestUser,ou=Users,dc=your,dc=ads,dc=domain)',\nattrs  => [ '1.1' ]\n);\n\nHow do I search for all members of a large group in AD?\nAD normally restricts the number of attribute values returned in one query. The exact number\ndepends on the AD server version: it was ~1000 in Win2000, 1500 in Win2003 and is 5000 in\nWin2008 & Win2008R2.\n\nPerforming the same standard search again will yield the same values again.\n\nSo, how can you get all members of a really large AD group?\n\nThe trick to use here is to use Microsoft's *range option* when searching, i.e instead of doing\none search for plain \"member\", perform multiple searches for e.g. \"member;range=1000-*\" where\nthe range starting index increases accordingly:\n\nmy $mesg;\nmy @members;\nmy $index = 0;\n\nwhile ($index ne '*') {\n$mesg = $ldap->search( base   => 'cn=Testgroup,dc=your,dc=ads,dc=domain',\nfilter => '(objectclass=group)',\nscope  => 'base',\nattrs  => [ ($index > 0) ? \"member;range=$index-*\" : 'member' ]\n);\nif ($mesg->code == LDAPSUCCESS) {\nmy $entry = $mesg->entry(0);\nmy $attr;\n\n# large group: let's do the range option dance\nif (($attr) = grep(/^member;range=/, $entry->attributes)) {\npush(@members, $entry->getvalue($attr));\n\nif ($attr =~ /^member;range=\\d+-(.*)$/) {\n$index = $1;\n$index++  if ($index ne '*');\n}\n}\n# small group: no need for the range dance\nelse {\n@members = $entry->getvalue('member');\nlast;\n}\n}\n# failure\nelse {\nlast;\n}\n}\n\nif ($mesg->code == LDAPSUCCESS) {\n# success: @members contains the members of the group\n}\nelse {\n# failure: deal with the error in $mesg\n}\n\nSee <http://msdn.microsoft.com/en-us/library/windows/desktop/aa367017.aspx> for more details.\n\nHow do I create a Microsoft Exchange 5.x user?\nThis is a solution provided by a perl-ldap user.\n\nThis code works with ActiveState Perl running on WinNT 4. Please note that this requires the\nWin32::Perms module, and needs valid NT account info to replace the placeholders.\n\nuse Net::LDAP;\nuse Net::LDAP::Util;\nuse Win32::Perms;\n\n#Constants taken from ADSI Type Library\n$ADSRIGHTEXCHADDCHILD = 1;\n$ADSRIGHTEXCHDELETE = 0x10000;\n$ADSRIGHTEXCHDSREPLICATION = 64;\n$ADSRIGHTEXCHDSSEARCH = 256;\n$ADSRIGHTEXCHMAILADMINAS = 32;\n$ADSRIGHTEXCHMAILRECEIVEAS = 16;\n$ADSRIGHTEXCHMAILSENDAS = 8;\n$ADSRIGHTEXCHMODIFYADMINATT = 4;\n$ADSRIGHTEXCHMODIFYSECATT = 128;\n$ADSRIGHTEXCHMODIFYUSERATT = 2;\n\n$EXCHUSERRIGHTS = $ADSRIGHTEXCHMAILRECEIVEAS |\n$ADSRIGHTEXCHMAILSENDAS |\n$ADSRIGHTEXCHMODIFYUSERATT;\n\n$exch = Net::LDAP->new('server', debug =>0) || die $@;\n\n$exch->bind( 'cn=adminuser,cn=ntdomain,cn=admin', version =>3,\npassword=>'password');\n\n$myObj = Win32::Perms->new();\n$Result = $myObj->Owner('ntdomain\\username');\n$myObj->Group('ntdomain\\Everyone');\n$myObj->Allow('ntdomain\\username',\n$EXCHUSERRIGHTS,OBJECTINHERITACE);\n$BinarySD = $myObj->GetSD(SDRELATIVE);\n$TextSD = uc(unpack( \"H*\", $BinarySD ));\nWin32::Perms::ResolveSid('ntdomain\\username', $sid);\n$mysid = uc(unpack(\"H*\",$sid));\n\n$result = $exch->add ( dn   =>\n'cn=username,cn=container,ou=site,o=organisation',\nattr => [ 'objectClass' => ['organizationalPerson'],\n'cn'   => 'directoryname',\n'uid' => 'mailnickname',\n'mail' => 'smtpaddress',\n'assoc-nt-account' => [ $mysid ],\n'nt-security-descriptor' => [ $TextSD ],\n'mailPreferenceOption'  => 0\n]\n);\n\n\nprint ldaperrorname($result->code);\n"
                },
                {
                    "name": "How do I reset a user's password ...",
                    "content": "... in most LDAP servers?\nMost LDAP servers use the standard userPassword attribute as the attribute to set when you want\nto change a user's password.\n\nThey usually allow one to set the password either using the regular modify operation on the\nuserPassword attribute or using the extended LDAP Password Modify operation defined in RFC3062.\n\nThe recommended method is the extended Password Modify operation, which offers a standardized\nway to set user passwords but unfortunately is not available on all LDAP servers.\n\nWhether the extended Password Modify operation is available can be found out by searching the\nattribute supportedExtension for the value 1.3.6.1.4.1.4203.1.11.1 in the RootDSE object.\n\nIf the extended Password Modify operation is not available the alternative is the regular\nmodification of the userPassword attribute.\n\nBut this method has some drawbacks:\n\n*   Depending on the type of the server the arguments to the modify operations may vary. Some\nwant the modify done with replace, some want it done by explicitly deleting the old password\nand add of the new one. This may even depend on whether you change the password for the\nbound user or as an administrator for another user.\n\n*   With the modify operation some servers expect the client to do the hashing of the password\non the client side. I.e. all clients that set passwords need to agree on the algorithm and\nthe format of the hashed password.\n\n*   Some LDAP servers do not allow setting the password if the connection is not sufficiently\nsecured. I.e. require SSL or TLS support to set the password (which is heavily recommended\nanyway ;-)\n\nHere is an example of how to change your own password (for brevity's sake error checking is left\nout):\n\nuse Net::LDAP;\n\nmy $ldap = Net::LDAP->new('ldaps://server.domain')  or  die \"$@\";\nmy $mesg = $ldap->bind('cn=Joe User,dc=perl,dc=ldap,dc=org',\npassword => 'oldPW');\n\nmy $rootdse = $ldap->rootdse();\n\nif ($rootdse->supportedextension('1.3.6.1.4.1.4203.1.11.1')) {\n\nrequire Net::LDAP::Extension::SetPassword;\n\n$mesg = $ldap->setpassword(user => 'cn=Joe User,dc=perl,dc=ldap,dc=org',\noldpasswd => 'oldPW',\nnewpasswd => 'newPW');\n}\nelse {\n$mesg = $ldap->modify('cn=Joe User,dc=perl,dc=ldap,dc=org',\nchanges => [\ndelete => [ userPassword => $oldPW ]\nadd    => [ userPassword => $newPW ] ]);\n}\n\n$ldap->unbind();\n\n... in MS Active Directory?\nWith Active Directory a user's password is stored in the unicodePwd attribute and changed using\nthe regular modify operation.\n\nADS expects this password to be encoded in Unicode - UTF-16 to be exact. Before the Unicode\nconversion is done the password needs to be surrounded by double quotes which do not belong to\nthe user's password.\n\nFor the password modify operation to succeed SSL is required.\n\nWhen changing the password for the user bound to the directory ADS expects it to be done by\ndeleting the old password and adding the new one. When doing it as a user with administrative\nprivileges replacing the unicodePwd's value with a new one is allowed too.\n\nPerl-ldap contains convenience methods for Active Directory that allow one to perform this task\nvery easily.\n\nHere's an example that demonstrates setting your own password from $oldPW to $newPW (again\nalmost no error checking):\n\nuse Net::LDAP;\nuse Net::LDAP::Extra qw(AD);\n\nmy $ldap = Net::LDAP->new('ldaps://ads.domain.controller')  or  die \"$@\";\n\nmy $mesg = $ldap->bind('cn=Joe User,dc=your,dc=ads,dc=domain',\npassword => $oldPW);\n\n$mesg = $ldap->changeADpassword('cn=Joe User,dc=your,dc=ads,dc=domain',\n$oldPW, $newPW);\n\n$ldap->unbind();\n\nAnd the same for perl-ldap versions before 0.49, where everything needs to be done by hand:\n\nuse Net::LDAP;\nuse Unicode::Map8;\nuse Unicode::String qw(utf16);\n\n# build the conversion map from your local character set to Unicode\nmy $charmap = Unicode::Map8->new('latin1')  or  die;\n\n# surround the PW with double quotes and convert it to UTF-16\n# byteswap() was necessary in experiments on i386 Linux, YMMV\nmy $oldUniPW = $charmap->tou('\"'.$oldPW.'\"')->byteswap()->utf16();\nmy $newUniPW = $charmap->tou('\"'.$newPW.'\"')->byteswap()->utf16();\n\nmy $ldap = Net::LDAP->new('ldaps://ads.domain.controller')  or  die \"$@\";\n\nmy $mesg = $ldap->bind('cn=Joe User,dc=your,dc=ads,dc=domain',\npassword => $oldPW);\n\n$mesg = $ldap->modify('cn=Joe User,dc=your,dc=ads,dc=domain',\nchanges => [\ndelete => [ unicodePwd => $oldUniPW ]\nadd    => [ unicodePwd => $newUniPW ] ]);\n\n$ldap->unbind();\n\nHow can I simulate server failover?\nPerl-ldap does not do server failover, however there are several programming options for getting\naround this situation.\n\nHere is one possible solution:\n\n$ldaps = Net::LDAPS->new([ $ldapserverone, $ldapservertwo ],\nport=>636, timeout=>5)  or  die \"$@\";\n\nFor perl-ldap versions before 0.27, the same goal can be achieved using:\n\nunless ( $ldaps =\nNet::LDAPS->new($ldapserverone,\nport=>636,timeout=>5) )\n{\n$ldaps = Net::LDAPS->new($ldapservertwo,\nport=>636,timeout=>20) ||\nreturn\n\"Can't connect to $ldapserverone or $ldapservertwo via LDAPS: $@\";\n}\n\nUsing X.509 certificates.\nHow do I store X.509 certificates in the directory?\nThe first problem here is that there are many different formats to hold certificates in, for\nexample PEM, DER, PKCS#7 and PKCS#12. The directory only uses the DER format (more correctly, it\nonly uses the BER format) which is a binary format.\n\nYour first job is to ensure that your certificates are therefore in DER/BER format. You could\nuse OpenSSL to convert from PEM like this:\n\nopenssl x509 -inform PEM -in cert.pem -outform DER -out cert.der\n\nConsult the OpenSSL documentation to find out how to perform other conversions.\n\nTo add a certificate to the directory, just slurp in the DER/BER certificate into a scalar\nvariable, and add it to the entry's userCertificate attribute. How you do that will depend on\nwhich version of LDAP you are using.\n\nTo slurp in the certificate try something like this:\n\nmy $cert;\n{\nlocal $/ = undef; # Slurp mode\nopen CERT, \"cert.der\" or die;\nbinmode CERT;     # for Windows e.a.\n$cert = <CERT>;\nclose CERT;\n}\n# The certificate is now in $cert\n\nFor LDAPv2, because most directory vendors ignore the string representation of certificates\ndefined in RFC 1778, you should add this value to the directory like this:\n\n$res = $ldap->modify(\"cn=My User, o=My Company,c=XY\",\nadd => [\n'userCertificate' => [ $cert ]\n]);\ndie \"Modify failed (\" . ldaperrorname($res->code) . \")\\n\"\nif $res->code;\n\nFor LDAPv3, you must do this instead:\n\n$res = $ldap->modify(\"cn=My User, o=My Company, c=XY\",\nadd => [\n'userCertificate;binary' => [ $cert ]\n]);\ndie \"Modify failed (\" . ldaperrorname($res->code) . \")\\n\"\nif $res->code;\n\nOf course, the entry you are trying to add the certificate to must use object classes that\npermit the userCertificate attribute, otherwise the modify will fail with an object class\nviolation error. The inetOrgPerson structural object class permits userCertificates, as does the\nstrongAuthenticationUser auxiliary object class. Others might also.\n"
                },
                {
                    "name": "How do I search objects by the contents of certificates.",
                    "content": "The directory needs to support one or more of the certificate*Match matching rules.\n\nThen using the filter (for certificateExactMatch)\n\n(userCertificate={ serialNumber 1234, issuer \"cn=CA,o=TrustCenter\" })\n\nallows searching for the objects containing the attribute userCertificate with a certificate\nmatching these criteria.\n\nPlease note that the exact syntax of the values for the serialNumber and the issuer above may\ndepend on the LDAP server. In any case the example above works with OpenLDAP 2.4.33.\n\nADDITIONAL DIRECTORY AND LDAP RESOURCES.\nURLs.\nNet::LDAP::Server - LDAP server framework in Perl\nhttp://search.cpan.org/search?module=Net::LDAP::Server https://github.com/alexrj/Net-LDAP-Server\n\nNet::LDAP::SimpleServer - LDAP server in Perl\nhttp://search.cpan.org/search?module=Net::LDAP::SimpleServer\nhttps://github.com/russoz/Net-LDAP-SimpleServer\n\nLemonLDAP::NG - Web SingleSignOn solution & SAML IdP in Perl http://lemonldap-ng.org/\n\nDancer::Plugin::LDAP - LDAP plugin for Dancer micro framework\nhttp://search.cpan.org/search?module=Dancer::Plugin::LDAP\nhttps://github.com/racke/Dancer-Plugin-LDAP\n\nDirectory Services Mark Language (DSML) http://www.oasis-open.org/specs/\n\neMailman LDAP information http://www.emailman.com/ldap/\n\nRafael Corvalan's LDAP shell http://sf.net/projects/ldapsh\n\nJeff Hodges's Kings Mountain LDAP http://www.kingsmountain.com/ldapRoadmap.shtml (outdated: last\nupdate was in 2004)\n\nwilleke.com's LDAP Wiki http://ldapwiki.willeke.com/wiki/LDAP\n\nOpenLDAP Directory Server - open source LDAP server. http://www.openldap.org/\n\n389 Directory Server - open source LDAP server http://port389.org/\n\nApacheDS - open source LDAP server in Java http://directory.apache.org/\n\nCriticalPath http://www.cp.net/\n\nForgeRock's OpenDS - LDAPv3 server with additional REST APIs\nhttp://www.forgerock.com/opendj.html\n\nIBM Tivoli Directory Server http://www-01.ibm.com/software/tivoli/products/directory-server/\n\nIsode (was MessagingDirect) http://www.isode.com/\n\nNexor's X.500 and Internet Directories http://www.nexor.com/info/directory.htm/\n\nNovell's eDirectory http://www.novell.com/\n\nOctet String http://www.octetstring.com/\n\nSUN JAVA JNDI (Java Naming and Directory Interface)\nhttp://java.sun.com/products/jndi/overview.html\n\nOracle Directory Server Enterprise Edition, formerly Sun One, formerly iPlanet.\nhttp://www.oracle.com/technetwork/middleware/id-mgmt/index-085178.html\n\nOptimalIDM - Virtual Identity Server - .NET LDAP virtual directory\nhttp://www.optimalidm.com/products/vis/Virtual-Directory-Server-VDS.aspx\n\nQuest One Quick Connect Virtual Directory Server - LDAP virtual directory\nhttp://www.quest.com/quest-one-quick-connect-virtual-directory-server/\n\nUnboundID's Identity data platform https://www.unboundid.com/\n\nVirtual Directory Blogger https://virtualdirectory.wordpress.com/\n\neldapo - a directory manager's blog http://eldapo.blogspot.de/\n\nEine deutsche LDAP Website A German LDAP Website\nhttp://verzeichnisdienst.de/ldap/Perl/index.html\n\n(non-exhaustive) list of LDAP software on Wikipedia\nhttp://en.wikipedia.org/wiki/ListofLDAPsoftware\n\n\"RFC Sourcebook\" on LDAP http://www.networksorcery.com/enp/protocol/ldap.htm\n\nweb2ldap - WWW gateway to LDAP server in Python http://www.web2ldap.de/\n\nSofterra LDAP Browser / Administrator http://www.ldapbrowser.com/\n\nThe 2 following URLs deal mainly with Microsoft's Active Directory.\n\nDirectory Works http://directoryworks.com/\n\nLDAP Client .Net & ActiveX LDAP Client http://www.ldapservices.com/Products/Default.aspx\n\nBOOKS\nDeveloping LDAP and ADSI Clients for Microsoft(R) Exchange. By Sven B. Schreiber. ISBN:\n0201657775\n\nImplementing LDAP. By Mark Wilcox. ISBN: 1861002211\n\nLDAP: Programming Directory-Enabled Applications With Lightweight Directory Access Protocol. By\nTim Howes, Mark Smith. ISBN: 1578700000\n\nLDAP Programming; Directory Management and Integration. By Clayton Donley. ISBN: 1884777910\n\nLDAP Programming with Java. By Rob Weltman, Tony Dahbura. ISBN: 0201657589\n\nLDAP System Administration. By Gerald Carter. ISBN: 1565924916\n\nManaging Enterprise Active Directory Services. By Robbie Allen, Richard Puckett. ISBN:\n0672321254\n\nSolaris and LDAP Naming Services. By Tom Bialaski, Michael Haines. ISBN: 0-13-030678-9\n\nUnderstanding and Deploying LDAP Directory Services (2ed). By Tim Howes, Mark Smith, Gordon\nGood. ISBN: 0672323168\n\nLDAP Directories Explained. By Brian Arkills. ISBN 0-201-78792-X\n"
                }
            ]
        },
        "AUTHORS": {
            "content": "Any good FAQ is made up of many authors, everyone that contributes information to the perl-ldap\nmail list is a potential author.\n\nAn attempt to maintain this FAQ is being done by Chris Ridd <chris.ridd@isode.com> and Peter\nMarschall <peter@adpm.de>. It was previously updated by Clif Harden <charden@pobox.com>.\n\nThe original author of this FAQ was Graham Barr <gbarr@pobox.com>\n\nPlease report any bugs, or post any suggestions, to the perl-ldap mailing list\n<perl-ldap@perl.org>.\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (c) 1999-2004 Graham Barr, (c) 2012 Peter Marschall. All rights reserved. This\ndocument is distributed, and may be redistributed, under the same terms as Perl itself.\n",
            "subsections": []
        }
    },
    "summary": "Net::LDAP::FAQ - Frequently Asked Questions about Net::LDAP",
    "flags": [],
    "examples": [],
    "see_also": []
}