403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.133.129.8
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /usr/local/share/man/man3/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/local/share/man/man3/Net::LDAP::FAQ.3pm
.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
.    if \nF \{
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "Net::LDAP::FAQ 3"
.TH Net::LDAP::FAQ 3 "2015-04-07" "perl v5.16.3" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
Net::LDAP::FAQ \- Frequently Asked Questions about Net::LDAP
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& perldoc Net::LDAP::FAQ
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This document serves to answer the most frequently asked questions on both the
perl-ldap Mailing List and those sent to Graham Barr.
.PP
The latest version of this \s-1FAQ\s0 can be found at
.PP
.Vb 1
\& http://ldap.perl.org/FAQ.html
.Ve
.SH "GENERAL"
.IX Header "GENERAL"
.SS "What is perl-ldap?"
.IX Subsection "What is perl-ldap?"
perl-ldap is the distribution name. The perl-ldap distribution contains
the Net::LDAP modules.
.SS "Why another Perl \s-1LDAP\s0 implementation?"
.IX Subsection "Why another Perl LDAP implementation?"
perl-ldap's goal is to be as portable as possible. It does this by
being implemented completely in Perl. So basically anywhere that Perl
runs perl-ldap will run. This is not true for other implementations
which require a C compiler.
.SS "Where can I get it?"
.IX Subsection "Where can I get it?"
Perl-ldap is available from \s-1CPAN.\s0
You can find the released versions at:
.PP
.Vb 1
\& http://search.cpan.org/dist/perl\-ldap/
.Ve
.SS "Is there a web page for perl-ldap?"
.IX Subsection "Is there a web page for perl-ldap?"
Yes there is at http://ldap.perl.org/
.SS "Is there a mailing list?"
.IX Subsection "Is there a mailing list?"
Yes there is at perl\-ldap@perl.org
.PP
You can subscribe to this list by mailing perl\-ldap\-subscribe@perl.org
.SS "Is the mailing list archived?"
.IX Subsection "Is the mailing list archived?"
Yes, at http://nntp.perl.org/group/perl.ldap
.PP
Archives with messages before we switched to using perl.org can be
found at
.PP
.Vb 1
\& http://marc.theaimsgroup.com/?l=perl\-ldap\-dev
.Ve
.PP
There is also an archive of the perl-ldap mailing list at
.PP
.Vb 1
\& http://www.xray.mpe.mpg.de/mailing\-lists/perl\-ldap/
.Ve
.PP
which also has messages from before the move.
.SS "Is there any online documentation?"
.IX Subsection "Is there any online documentation?"
Yes. perl-ldap has online documentation at
.PP
.Vb 1
\& http://ldap.perl.org/
.Ve
.PP
which will have the latest documentation available.
.SS "Is there a public repository?"
.IX Subsection "Is there a public repository?"
Yes, there is a public Git repository at
.PP
.Vb 1
\& https://github.com/perl\-ldap/perl\-ldap
.Ve
.SS "Can I get perl-ldap from the public Git repository?"
.IX Subsection "Can I get perl-ldap from the public Git repository?"
Yes, anyone can pull perl-ldap from the public Git repository
on GitHub.
.PP
There are several ways this can be done \- see below.
.IP "\s-1CPAN\s0" 4
.IX Item "CPAN"
You can download it from \s-1CPAN\s0 by following the \*(L"Download\*(R" link on:
.Sp
.Vb 1
\& http://search.cpan.org/dist/perl\-ldap/
.Ve
.Sp
Example;
.Sp
.Vb 1
\& http://search.cpan.org/CPAN/authors/id/M/MA/MARSCHAP/perl\-ldap\-0.54.tar.gz
.Ve
.IP "Git \- fork on GitHub" 4
.IX Item "Git - fork on GitHub"
If you have an account on GitHub (there's a free variant), you can easily
fork the perl-ldap repository on GitHub.
When logged on to GitHub, navigate to the perl-ldap repository
.Sp
.Vb 1
\& https://github.com/perl\-ldap/perl\-ldap
.Ve
.Sp
and simply click on the \*(L"Fork\*(R" button near the top-right corner.
.IP "Git \- clone repository" 4
.IX Item "Git - clone repository"
You can download latest development version of perl-ldap from
GitHub by cloning the repository using the command:
.Sp
.Vb 1
\& git clone https://github.com/perl\-ldap/perl\-ldap.git
.Ve
.Sp
This command will create a directory named 'perl\-ldap' in your
current directory containing a local clone of the repository.
.Sp
Keeping your local repository in sync with perl-ldap's GitHub repository
is easy:
.Sp
.Vb 2
\&  cd perl\-ldap
\&  git pull
.Ve
.IP "Web page" 4
.IX Item "Web page"
Most of the time there is a \s-1URL\s0 link on the perl-ldap
home page on ldap.perl.org that points to the latest released
version of perl-ldap.  Due to the fact that humans must
update the web page to point to a new release it sometimes does
not get updated as quickly as it should.
.SS "What is Git?"
.IX Subsection "What is Git?"
Git (see http://git\-scm.com) is a distributed version control system
designed to keep track of source changes made by groups of developers
working on the same files, allowing them to stay in sync with each other
as each individual chooses.
.SH "LDAP AND DIRECTORY TERMINOLOGY."
.IX Header "LDAP AND DIRECTORY TERMINOLOGY."
In order to help the user understand the perl-ldap module better
some key \s-1LDAP\s0 terminology is defined here.
.SS "What is a directory?"
.IX Subsection "What is a directory?"
A directory is a special purpose hierarchical database that usually
contains typed information such as text strings, binary data, or X.509
certificates.
.SS "What is \s-1LDAP\s0?"
.IX Subsection "What is LDAP?"
\&\s-1LDAP\s0 stands for Lightweight Directory Access Protocol.
The word \fIProtocol\fR is the key word in the definition given in
the preceding sentence, \s-1LDAP\s0 is \fI\s-1NOT\s0\fR hardware or software.
It is a protocol that defines how a client and server will
communicate with one another.
.PP
The Lightweight Directory Access Protocol is defined in a series of
Requests For Comments, better known as RFCs. The RFCs can be found on
the Internet at http://www.ietf.org/ (the master repository) and many
other places. There's a link to all the LDAP-related RFCs at
perl-ldap's web site, http://ldap.perl.org/rfc.html. Some of the more
important \s-1RFC\s0 numbers are \s-1RFC 4510 \- 4519\s0 for \s-1LDAP \s0(previously called
LDAPv3) and the historic \s-1RFC 1777\s0 for LDAPv2.
.SS "What is a \s-1LDAP\s0 Directory?"
.IX Subsection "What is a LDAP Directory?"
In the strictest terms of the definition there is no such thing as a
\&\s-1LDAP\s0 directory.  To be practical about this situation every day
directory professionals refer to their directory as \*(L" a \s-1LDAP\s0
directory\*(R" because it is easy to say and it does convey the type of
protocol used to communicate with their directory.  Using this
definition a \s-1LDAP\s0 directory is a directory whose server software
conforms to the Lightweight Directory Access Protocol when
communicating with a client.
.SS "What is an Entry?"
.IX Subsection "What is an Entry?"
The traditional directory definition of a directory object
is called an Entry. Entries are composed of attributes that
contain the information to be recorded about the object.
.PP
(An entry in \s-1LDAP\s0 is somewhat analogous to a record in a table in an
\&\s-1SQL\s0 database, but don't get too hung up about this analogy!)
.PP
Entries are held in an upside-down tree structure. Entries can
therefore contain subordinate entries, and entries \fBmust\fR have one
direct superior entry.
.PP
Entries with subordinate entries are called 'non\-leaf' entries.
.PP
Entries without subordinate entries are called 'leaf' entries.
.PP
An entry's direct superior entry is called the entry's 'parent'.
.PP
\&'Non\-leaf' entries are also said to have 'child' entries.
.SS "What is an attribute?"
.IX Subsection "What is an attribute?"
The entry(s) in a directory are composed of attributes that contain
information about the object.  Each attribute has a type
and can contain one or more values.
.PP
For example:
.PP
.Vb 1
\&  cn=Road Runner
.Ve
.PP
is an attribute with a type named \*(L"cn\*(R", and one value.
.PP
Each attribute is described by a 'syntax' which defines what kind of
information can be stored in the attributes values.  Trying to store a
value that doesn't conform to the attribute's syntax will result in an
error.
.PP
For example:
.PP
.Vb 1
\&  jpegPhoto=unknown
.Ve
.PP
is not permitted by the directory, because jpegPhotos may only contain
JPEG-formatted images.
.PP
Most syntaxes used in \s-1LDAP\s0 however describe text strings rather than
binary objects (like JPEGs or certificates.)
.PP
In LDAPv3 most of these syntaxes support Unicode encoded using
\&\s-1UTF\-8.\s0 Because the Net::LDAP modules do not change the strings that
you pass in as attribute values (they get sent to the \s-1LDAP\s0 server
as-is) to use accented characters you simply need to encode your
strings in \s-1UTF\-8.\s0 There are modules on \s-1CPAN\s0 that will help you here.
.PP
Note that LDAPv2 servers used something called T.61 instead of Unicode
and \s-1UTF\-8.\s0 Most servers do not implement T.61 correctly, and it is
recommended that you use LDAPv3 instead.
.PP
Attributes may also be searched.  The algorithms used to perform
different kinds of searches are described by the attribute's 'matching
rules'.  Some matching rules are case-sensitive and some are
case-insensitive, for example.  Sometimes matching rules aren't
defined for a particular attribute: there's no way to search for
jpegPhotos that contain a substring!
.PP
You can examine all of a server's attribute definitions by reading the
schema from the server.
.SS "What is an object class?"
.IX Subsection "What is an object class?"
An object class is the name associated with a group of attributes that
\&\fBmust\fR be present in an entry, and the group of attributes that
\&\fBmay\fR also be present in an entry.
.PP
Object classes may be derived (subclassed) from other object classes.
For example the widely used 'inetOrgPerson' object class is derived
from 'organizationalPerson', which is itself derived from 'person'
which is itself derived from 'top'.
.PP
Every entry has an attribute called 'objectClass' that lists all the
names of object classes (and their superclasses) being used with the
entry.
.PP
You can examine all of a server's objectclass definitions by reading
the schema from the server.
.SS "What is a Distinguished Name (\s-1DN\s0)?"
.IX Subsection "What is a Distinguished Name (DN)?"
Every entry in a directory has a Distinguished Name, or \s-1DN. \s0 It is a
unique Entry identifier throughout the complete directory.  No two
Entries can have the same \s-1DN\s0 within the same directory.
.PP
Examples of DNs:
.PP
.Vb 4
\& cn=Road Runner, ou=bird, dc=cartoon, dc=com
\& ou=bird, dc=cartoon, dc=com
\& dc=cartoon, dc=com
\& dc=com
.Ve
.SS "What is a Relative Distinguished Name?"
.IX Subsection "What is a Relative Distinguished Name?"
Every \s-1DN\s0 is made up of a sequence of Relative Distinguished Names, or
RDNs.  The sequences of RDNs are separated by commas (,). In LDAPv2
semi-colons (;) were also allowed.  There can be more than one
identical \s-1RDN\s0 in a directory, but they must have different parent
entries.
.PP
Technically, an \s-1RDN\s0 contains attribute-value assertions, or AVAs. When
an \s-1AVA\s0 is written down, the attribute name is separated from the
attribute value with an equals (=) sign.
.PP
Example of a \s-1DN:\s0
.PP
.Vb 1
\& cn=Road Runner,ou=bird,dc=cartoon,dc=com
\&
\& RDNs of the proceeding DN:
\& RDN => cn=Road Runner
\& RDN => ou=bird
\& RDN => dc=cartoon
\& RDN => dc=com
.Ve
.PP
RDNs can contain multiple attributes, though this is somewhat
unusual. They are called multi-AVA RDNs, and each \s-1AVA\s0 is separated in
the \s-1RDN\s0 from the others with a plus sign (+).
.PP
Example of a \s-1DN\s0 with a multi-AVA \s-1RDN:\s0
.PP
.Vb 1
\& cn=Road Runner+l=Arizona,ou=bird,dc=cartoon,dc=com
.Ve
.SS "Where is an entry's name held?"
.IX Subsection "Where is an entry's name held?"
Entries do \fBnot\fR contain their \s-1DN.\s0 When you retrieve an entry from
a search, the server will tell you the \s-1DN\s0 of each entry.
.PP
On the other hand, entries \fBdo\fR contain their \s-1RDN.\s0 Recall that the \s-1RDN\s0
is formed from one or more attribute-value assertions (AVAs); each entry
must contain all the attributes and values in the \s-1RDN.\s0
.PP
For example the entry:
.PP
.Vb 1
\& cn=Road Runner+l=Arizona,ou=bird,dc=cartoon,dc=com
.Ve
.PP
\&\fBmust\fR contain a 'cn' attribute containing at least the value
\&\*(L"Road Runner\*(R", \fBand\fR an 'l' attribute containing at least the value
\&\*(L"Arizona\*(R".
.PP
The attributes used in the \s-1RDN\s0 may contain additional values, but the
entry still only has one \s-1DN.\s0
.SS "What is a search base?"
.IX Subsection "What is a search base?"
A search base is a Distinguished Name that is the
starting point of search queries.
.PP
Example of a \s-1DN:\s0
.PP
.Vb 1
\& cn=Road Runner,ou=bird,dc=cartoon,dc=com
.Ve
.PP
Possible search base(s) for the proceeding \s-1DN:\s0
.PP
.Vb 4
\& Base => cn=Road Runner,ou=bird,dc=cartoon,dc=com
\& Base => ou=bird,dc=cartoon,dc=com
\& Base => dc=cartoon,dc=com
\& Base => dc=com
.Ve
.PP
Setting the search base to the lowest possible branch of
the directory will speed up searches considerably.
.SS "What is the difference between a \s-1LDAP\s0 server and a relational database?"
.IX Subsection "What is the difference between a LDAP server and a relational database?"
The most basic difference is that a directory server is a
specialized database designed to provide fast searches. While a relational
database is optimized for transactions (where a series of operations is
counted as 1, thus if one of the steps fails, the \s-1RDBMS\s0 can roll-back to
the state it was in before you started).
.PP
Directories also typically are hierarchical in nature (\s-1RDBMS\s0 is typically
flat, but you can implement a hierarchy using tables and queries),
networkable, distributed and replicated.
.PP
\&\s-1LDAP\s0 provides an open-standard to a directory service.
.PP
Typically we use \s-1LDAP\s0 for email directories (all popular email clients
provide an \s-1LDAP\s0 client now) and authorization services (authentication and
access control).
.PP
You could use a \s-1RDBMS\s0 for these types of queries but there's no
set standard, in particular over \s-1TCP/IP\s0 to connect to databases over the
network. There's language specific protocols (like Perl's \s-1DBI\s0 and Java's
\&\s-1JDBC\s0) that hide this problem behind an \s-1API\s0 abstraction, but that's not a
replacement for a standard access protocol.
.PP
\&\s-1LDAP\s0 is starting to be used on roles traditionally played by \s-1RDBMS\s0 in
terms of general data management because it's easier to setup a \s-1LDAP\s0
server (once you understand the basic nomenclature) and you don't need
a \s-1DBA\s0 to write your queries and more importantly all \s-1LDAP\s0 servers speak
the same essential protocol, thus you don't have to fuss with a
database driver trying to connect it to the Internet. Once you have an
\&\s-1LDAP\s0 server up and running, it's automatically available over the 'net.
It's possible to connect to a \s-1LDAP\s0 server from a variety of mechanisms,
including just about every possible programming language.
.PP
More information on this topic can be found on the following URLs;
.PP
.Vb 1
\& http://www.openldap.org/faq/data/cache/378.html
\&
\& http://www.isode.com/whitepapers/ic\-6055.html
.Ve
.SS "What is the difference between a ldap reference and a ldap referral?"
.IX Subsection "What is the difference between a ldap reference and a ldap referral?"
A referral is returned when the \fBentire\fR operation must be resent to
another server.
.PP
A continuation reference is returned when \fBpart\fR of the operation must be
resent to another server.
.PP
See \s-1RFC 4511\s0 section 4.5.3 for more details.
.SH "perl-ldap INSTALLATION"
.IX Header "perl-ldap INSTALLATION"
.SS "How do I install perl-ldap?"
.IX Subsection "How do I install perl-ldap?"
To install the modules that are in the perl-ldap distribution follow the
same steps that you would for most other distributions found on \s-1CPAN,\s0 that
is
.PP
.Vb 1
\&   # replace 0.62 with the version you have
\&
\&   gunzip perl\-ldap\-0.62.tar.gz
\&   tar xvf perl\-ldap\-0.62.tar
\&   cd perl\-ldap\-0.62
\&
\&   perl Makefile.PL
\&   make
\&   make test
\&   make install
.Ve
.SS "But I do not have make, how can I install perl-ldap?"
.IX Subsection "But I do not have make, how can I install perl-ldap?"
Well as luck would have it the modules in perl-ldap do not do anything
complex, so a simple copy is enough to install. First run
.PP
.Vb 1
\&  perl \-V
.Ve
.PP
This will output information about the version of Perl you have
installed. Near the bottom you will find something like
.PP
.Vb 8
\&  @INC:
\&    /usr/local/lib/perl/5.18.2
\&    /usr/local/share/perl/5.18.2
\&    /usr/lib/perl5
\&    /usr/share/perl5
\&    /usr/lib/perl/5.18
\&    /usr/share/perl/5.18
\&    /usr/local/lib/site_per
.Ve
.PP
This is a list of directories that Perl searches when it is looking for
a module. The directory you need is the site_perl directory, but without
the system architecture name, in this case it is
\&\f(CW\*(C`/usr/local/lib/site_perl\*(C'\fR. The files required
can then be installed with
.PP
.Vb 1
\&   # replace 0.62 with the version you have
\&
\&   gunzip perl\-ldap\-0.62.tar.gz
\&   tar xvf perl\-ldap\-0.62.tar
\&   cd perl\-ldap\-0.62/lib
\&
\&   cp \-r * /usr/local/lib/site_perl
.Ve
.SS "How can I load perl-ldap into an ActiveState Perl installation?"
.IX Subsection "How can I load perl-ldap into an ActiveState Perl installation?"
There are several ways that perl-ldap can be installed into an
ActiveState Perl tree.
.IP "1." 4
The ActiveState ppm command can be used to install perl-ldap.
When a new version of perl-ldap is released, it takes ActiveState
a period of time to get the new release into the ActiveState ppm
system.
.IP "2." 4
If the user has nmake installed, the user can do a normal Perl
module install using nmake instead of make.
.IP "3." 4
If the user does not have nmake or make, the user can install
perl-ldap using the install-nomake script by issuing the
following command.
.Sp
.Vb 1
\& perl install\-nomake
.Ve
.Sp
The install-nomake script can be used on any system that does not
have make installed.
.SS "What other modules will I need?"
.IX Subsection "What other modules will I need?"
perl-ldap uses other Perl modules. Some are required, but some are
optional (i.e. required to use certain features only).
.PP
If you are using a Linux system, many of the distributions
have packages that you can install using the distribution's
package management tools (e.g. apt, rpm, ...).
.PP
Alternatively, you may use your favorite web search engine
to find the package that you need.
.IP "Convert::ASN1" 4
.IX Item "Convert::ASN1"
This module converts between Perl data structures and \s-1ASN.1,\s0 and
is required for perl-ldap to work.
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=Convert::ASN1
.IP "OpenSSL and IO::Socket::SSL" 4
.IX Item "OpenSSL and IO::Socket::SSL"
If you want to use encrypted connections, either via start_tls
or \s-1LDAPS\s0 connections, you will need this module
and the OpenSSL software package.
.Sp
You can obtain the latest release of IO::Socket::SSL from
  http://search.cpan.org/search?module=IO::Socket::SSL
.Sp
You can obtain the latest release of OpenSSL from
  http://www.openssl.org/
.IP "IO::Socket::INET6" 4
.IX Item "IO::Socket::INET6"
For connecting to \s-1LDAP\s0 servers via IPv6, IO::Socket::INET6 is required.
Its presence is detected at runtime, so that perl-ldap can be installed
without it, and automatically gains IPv6 support as soon as
IO::Socket::INET6 gets installed.
.Sp
You can obtain the latest releases from
  http://search.cpan.org/search?module=IO::Socket::INET6
.IP "IO::Socket::IP" 4
.IX Item "IO::Socket::IP"
This is an alternative to using IO::Socket::INET6. Like that module, it gets
detected automatically at runtime. If version 0.20 or higher is installed, is
is preferred over IO::Socket::INET6 and IO::Socket::INET for all \s-1IP\s0 connections.
.Sp
You can obtain the latest releases from
  http://search.cpan.org/search?module=IO::Socket::IP
.IP "Authen::SASL" 4
.IX Item "Authen::SASL"
This module is optional.  You only need to install Authen::SASL
if you want to use the \s-1SASL\s0 authentication methods.
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=Authen::SASL
.IP "Digest::MD5" 4
.IX Item "Digest::MD5"
This module is optional. It also requires a C compiler when installing.
You only need to install Digest::MD5 if you want to use the \s-1SASL
DIGEST\-MD5\s0 authentication mechanism.
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=Digest::MD5
.Sp
As Digest::MD5 is part of the Perl core modules since Perl 5.7.3,
you only need a C compiler if you want to install a version that is
newer than the version distributed with your Perl installation.
.IP "Digest::HMAC_MD5" 4
.IX Item "Digest::HMAC_MD5"
This optional module is required only if you want to use the \s-1SASL
CRAM\-MD5\s0 authentication mechanism.
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=Digest::HMAC_MD5
.IP "\s-1GSSAPI\s0" 4
.IX Item "GSSAPI"
This optional module is required only if you want to use the \s-1SASL
GSSAPI\s0 authentication mechanism (e.g. for Kerberos authentication).
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=GSSAPI
.IP "URI::ldap, URI::ldaps, and URI::ldapi" 4
.IX Item "URI::ldap, URI::ldaps, and URI::ldapi"
These modules are optional. You only need to install them if you
want to parse ldap://, ldaps:// or ldapi:// URIs using
ldap_parse_uri in Net::LDAP::Util.
or use LWP::Protocol::ldap, LWP::Protocol::ldaps, or LWP::Protocol::ldapi.
.Sp
You can obtain the latest releases from
  http://search.cpan.org/search?module=URI::ldap
  http://search.cpan.org/search?module=URI::ldaps
  http://search.cpan.org/search?module=URI::ldapi
.IP "LWP::Protocol, LWP::MediaTypes, HTTP::Negotiate, and HTTP::Response" 4
.IX Item "LWP::Protocol, LWP::MediaTypes, HTTP::Negotiate, and HTTP::Response"
These optional modules are needed if you want to use perl-ldap's
LWP::Protocol::ldap, LWP::Protocol::ldaps, or LWP::Protocol::ldapi modules.
.Sp
You can obtain the latest releases from
 http://search.cpan.org/search?module=LWP::Protocol
 http://search.cpan.org/search?module=LWP::MediaTypes
 http://search.cpan.org/search?module=HTTP::Negotiate
 http://search.cpan.org/search?module=HTTP::Response
.IP "\s-1JSON\s0" 4
.IX Item "JSON"
This optional module is required for JSON-formatted output of perl-ldap's
LWP::Protocol::ldap, LWP::Protocol::ldaps, or LWP::Protocol::ldapi modules.
.Sp
If you need it, you can obtain the latest releases from
 http://search.cpan.org/search?module=JSON
.IP "Time::Local" 4
.IX Item "Time::Local"
This module is optional, and only required if you want to convert
between \s-1UNIX\s0 time and generalizedTime using the functions provided
in Net::LDAP::Util.
.IP "\s-1XML::SAX\s0 and XML::SAX::Writer" 4
.IX Item "XML::SAX and XML::SAX::Writer"
If you want to parse or write DSMLv1 documents with Net::LDAP::DSML
to you will need these optional modules.
.Sp
You can obtain the latest releases from
  http://search.cpan.org/search?module=XML::SAX
  http://search.cpan.org/search?module=XML::SAX::Writer
.IP "ResourcePool::Factory::Net::LDAP" 4
.IX Item "ResourcePool::Factory::Net::LDAP"
If you want to use failover the ResourcePool::Factory::Net::LDAP
Perl module provides methods to do this.
.Sp
You can obtain the latest release from
  http://search.cpan.org/search?module=ResourcePool::Factory::Net::LDAP
.SH "USING NET::LDAP"
.IX Header "USING NET::LDAP"
.SS "How do I connect to my server?"
.IX Subsection "How do I connect to my server?"
The connection to the server is created when you create a new Net::LDAP
object, e.g.
.PP
.Vb 1
\&  $ldap = Net::LDAP\->new($server);
.Ve
.SS "Net::LDAP\->new sometimes returns undef, why?"
.IX Subsection "Net::LDAP->new sometimes returns undef, why?"
The constructor will return undef if there was a problem connecting
to the specified server. Any error message will be available in $@
.SS "What is the proper format of the bind \s-1DN\s0?"
.IX Subsection "What is the proper format of the bind DN?"
The \s-1DN\s0 used to bind to a directory is a \s-1FULLY QUALIFIED DN. \s0 The exact
structure of the \s-1DN\s0 will depend on what data has been stored in the
server.
.PP
The following are valid examples.
.PP
.Vb 1
\&  uid=clif,ou=People,dc=umich,dc=edu
\&
\&  cn=directory manager,ou=admins,dc=umich,dc=edu
.Ve
.PP
In some servers the following would be a valid fully qualified \s-1DN\s0 of
the directory manager.
.PP
.Vb 1
\&  cn=directory manager
.Ve
.SS "How can I tell when the server returns an error, \fIbind()\fP always returns true?"
.IX Subsection "How can I tell when the server returns an error, bind() always returns true?"
Most methods in Net::LDAP return a Net::LDAP::Message
object, or a sub-class of that. This object will hold the results
from the server, including the result code.
.PP
So, for example, to determine the result of the bind operation.
.PP
.Vb 1
\&  $mesg = $ldap\->bind( $dn, password => $passwd );
\&
\&  if ( $mesg\->code ) {
\&    # Handle error codes here
\&  }
.Ve
.SS "How can I set the \s-1LDAP\s0 version of a connection to my \s-1LDAP\s0 server?"
.IX Subsection "How can I set the LDAP version of a connection to my LDAP server?"
This is done by adding the version option when connecting or binding
to the \s-1LDAP\s0 server.
.PP
For example;
.PP
.Vb 1
\&  $ldap = Net::LDAP\->new( $server, version => 3 );
.Ve
.PP
or
.PP
.Vb 1
\&  $mesg = $ldap\->bind( $dn, password => $passwd, version => 3 );
.Ve
.PP
Valid version numbers are 2 and 3.
As of perl-ldap 0.27 the default \s-1LDAP\s0 version is 3.
.SS "I did a search on my directory using the 'search' method. Where did the results go?"
.IX Subsection "I did a search on my directory using the 'search' method. Where did the results go?"
Your search results are stored in a 'search object'.
Consider the following:
.PP
.Vb 1
\& use Net::LDAP;
\&
\& $ldap = Net::LDAP\->new(\*(Aqldap.acme.com\*(Aq) or die "$@";
\& $mesg = $ldap\->search(
\&                       base   => "o=acme.com",
\&                       filter => "uid=jsmith",
\&                      );
.Ve
.PP
\&\f(CW$mesg\fR is a search object. It is a reference blessed into the
Net::LDAP::Search package. By calling methods on this object you
can obtain information about the result and also the individual
entries.
.PP
The first thing to check is if the search was successful. This is done
with the method \f(CW$mesg\fR\->code. This method will return the
status code that the server returned. A success will yield a zero
value, but there are other values, some of which could also be
considered a success.  See Net::LDAP::Constant
.PP
.Vb 1
\&  use Net::LDAP::Util qw(ldap_error_text);
\&
\&  die ldap_error_text($mesg\->code)
\&    if $mesg\->code;
.Ve
.PP
There are two ways in which you can access the entries. You can access
then with an index or you can treat the container like a stack and
shift each entry in turn. For example
.PP
.Vb 1
\&  # as an array
\&
\&  # How many entries were returned from the search
\&  my $max = $mesg\->count;
\&
\&  for (my $index = 0 ; $index < $max ; $index++) {
\&    my $entry = $mesg\->entry($index);
\&    # ...
\&  }
\&
\&  # or as a stack
\&
\&  while (my $entry = $mesg\->shift_entry) {
\&    # ...
\&  }
.Ve
.PP
In each case \f(CW$entry\fR is an entry object. It is a reference blessed into
the Net::LDAP::Entry package. By calling methods on this object you
can obtain information about the entry.
.PP
For example, to obtain the \s-1DN\s0 for the entry
.PP
.Vb 1
\&  $dn = $entry\->dn;
.Ve
.PP
To obtain the attributes that a given entry has
.PP
.Vb 1
\&  @attrs = $entry\->attributes;
.Ve
.PP
And to get the list of values for a given attribute
.PP
.Vb 1
\&  @values = $entry\->get( \*(Aqsn\*(Aq );
.Ve
.PP
And to get the first of the values for a given attribute
.PP
.Vb 1
\&  $values = $entry\->get( \*(Aqcn\*(Aq );
.Ve
.PP
One thing to remember is that attribute names are case
insensitive, so 'sn', 'Sn', 'sN' and '\s-1SN\s0' are all the same.
.PP
So, if you want to print all the values for the attribute \f(CW\*(Aqou\*(Aq\fR then this
is as simple as
.PP
.Vb 3
\&  foreach ($entry\->get_value( \*(Aqou\*(Aq )) {
\&      print $_,"\en";
\&    }
.Ve
.PP
Now if you just want to print all the values for all the attributes you
can do
.PP
.Vb 5
\&  foreach my $attr ($entry\->attributes) {
\&    foreach my $value ($entry\->get_value($attr)) {
\&      print $attr, ": ", $value, "\en";
\&    }
\&  }
.Ve
.SS "How do I limit the scope of a directory search?"
.IX Subsection "How do I limit the scope of a directory search?"
You limit the scope of a directory search by setting the
scope parameter of search request.
Consider the following:
.PP
.Vb 1
\& use Net::LDAP;
\&
\& $ldap = Net::LDAP\->new(\*(Aqldap.acme.com\*(Aq) or die "$@";
\& $mesg = $ldap\->search(
\&                       base   => "o=acme.com",
\&                       scope  => \*(Aqsub\*(Aq,
\&                       filter => "uid=jsmith",
\&                      );
.Ve
.PP
Values for the scope parameter are as follows.
.IP "base" 4
.IX Item "base"
Search only the base object.
.IP "one" 4
.IX Item "one"
Search the entries immediately below the base object.
.IP "sub" 4
.IX Item "sub"
.PD 0
.IP "subtree" 4
.IX Item "subtree"
.PD
Search the whole tree below (and including) the base object.
This is the default.
.IP "children" 4
.IX Item "children"
Search the whole subtree below the base object, excluding the base object itself.
.Sp
Note: \fIchildren\fR scope requires LDAPv3 subordinate feature extension.
.SH "GETTING SEARCH RESULTS"
.IX Header "GETTING SEARCH RESULTS"
There are two ways of retrieving the results of a requested
\&\s-1LDAP\s0 search; inline and by using a callback subroutine.
.SS "\s-1USING THE INLINE APPROACH\s0"
.IX Subsection "USING THE INLINE APPROACH"
Using the inline approach involves requesting the data and
then waiting for all of the data to be returned before the
user starts processing the data.
.PP
Example:
.PP
.Vb 1
\& use Net::LDAP;
\&
\& $ldap = Net::LDAP\->new(\*(Aqldap.acme.com\*(Aq) or die "$@";
\& $mesg = $ldap\->search(
\&                       base   => "o=acme.com",
\&                       scope  => \*(Aqsub\*(Aq,
\&                       filter => "sn=smith",
\&                      );
\& #
\& # At this point the user can get the returned data as an array
\& # or as a stack.
\& # In this example we will use an array
\&
\& # How many entries were returned from the search
\& my $max = $mesg\->count;
\&
\& for (my $index = 0 ; $index < $max ; $index++)
\& {
\&   my $entry = $mesg\->entry($index);
\&   my $dn = $entry\->dn; # Obtain DN of this entry
\&
\&   @attrs = $entry\->attributes; # Obtain attributes for this entry.
\&   foreach my $var (@attrs)
\&   {
\&     #get a list of values for a given attribute
\&     $attr = $entry\->get_value( $var, asref => 1 );
\&     if ( defined($attr) )
\&     {
\&       foreach my $value ( @$attr )
\&       {
\&         print "$var: $value\en";  # Print each value for the attribute.
\&       }
\&     }
\&   }
\& }
.Ve
.PP
As you can see the example is straightforward, but there is one
drawback to this approach.  You must wait until all entries for the
request search to be returned before you can process the data.  If
there several thousand entries that match the search filter this
could take quite a long time period.
.SS "\s-1USING THE CALLBACK SUBROUTINE APPROACH\s0"
.IX Subsection "USING THE CALLBACK SUBROUTINE APPROACH"
Using the callback approach involves requesting the data be sent
to a callback subroutine as each entry arrives at the client.
.PP
A callback is just a subroutine that is passed two parameters when
it is called, the mesg and entry objects.
.PP
Example:
.PP
.Vb 1
\& use Net::LDAP;
\&
\& $ldap = Net::LDAP\->new(\*(Aqldap.acme.com\*(Aq) or die "$@";
\& $mesg = $ldap\->search(
\&                       base   => "o=acme.com",
\&                       scope  => \*(Aqsub\*(Aq,
\&                       filter => "sn=smith",
\&                       callback => \e&callback,
\&                      );
\& #
\& # At this point the user needs to check the status of the
\& # ldap search.
\& #
\&
\& if ( $mesg\->code )
\& {
\&    $errstr = $mesg\->code;
\&    print "Error code:  $errstr\en";
\&    $errstr = ldap_error_text($errstr);
\&    print "$errstr\en";
\& }
\&
\&
\& sub callback
\& {
\& my ( $mesg, $entry) = @_;
\&
\&   #
\&   # First you must check to see if something was returned.
\&   # Last execution of callback subroutine will have no
\&   # defined entry and mesg object
\&   #
\&   if ( !defined($entry) )
\&   {
\&     print "No records found matching filter $match.\en"
\&     if ($mesg\->count == 0) ; # if mesg is not defined nothing will print.
\&     return;
\&   }
\&
\&   my $dn = $entry\->dn; # Obtain DN of this entry
\&
\&   @attrs = $entry\->attributes; # Obtain attributes for this entry.
\&   foreach my $var (@attrs)
\&   {
\&    #get a list of values for a given attribute
\&    $attr = $entry\->get_value( $var, asref => 1 );
\&    if ( defined($attr) )
\&    {
\&      foreach my $value ( @$attr )
\&      {
\&        print "$var: $value\en";  # Print each value for the attribute.
\&      }
\&    }
\&   }
\&   #
\&   # For large search requests the following line of code
\&   # may be very important, it will reduce the amount of memory
\&   # used by the search results.
\&   #
\&   # If the user is not worried about memory usage then the line
\&   # of code can be omitted.
\&   #
\&   $mesg\->pop_entry;
\&
\& }  # End of callback subroutine
.Ve
.PP
As you can see the example is straightforward and it does not waste
time waiting for all of the entries to be returned.  However if the
pop_entry method is not used the callback approach can allocate a
lot of memory to the search request.
.SH "USING NET::LDAPS"
.IX Header "USING NET::LDAPS"
.SS "Using an \s-1SSL\s0 network connection, how do I connect to my server?"
.IX Subsection "Using an SSL network connection, how do I connect to my server?"
This class is a subclass of Net::LDAP so all the normal
Net::LDAP methods can be used with a Net::LDAPS object;
see the documentation for Net::LDAP to find out how to
query a directory server using the \s-1LDAP\s0 protocol.
.PP
The connection to the server is created when you create a new Net::LDAPS
object, e.g.
.PP
.Vb 5
\&  $ldaps = Net::LDAPS\->new($server,
\&                           port => \*(Aq10000\*(Aq,
\&                           verify => \*(Aqrequire\*(Aq,
\&                           capath => \*(Aq/usr/local/cacerts/\*(Aq,
\&                           );
.Ve
.PP
Starting with version 0.28 perl-ldap also supports URIs in the new method.
So, the above can also be expressed as:
.PP
.Vb 5
\&  $ldaps = Net::LDAP\->new("ldaps://$server",
\&                           port => \*(Aq10000\*(Aq,
\&                           verify => \*(Aqrequire\*(Aq,
\&                           capath => \*(Aq/usr/local/cacerts/\*(Aq,
\&                           );
.Ve
.PP
There are additional options to the new method with \s-1LDAPS\s0 URIs
and the \s-1LDAPS\s0 new method and several additional methods are
included in the \s-1LDAPS\s0 object class.
.PP
For further information and code examples read the \s-1LDAPS\s0
module documentation;  perldoc Net::LDAPS
.SH "USING LDAP GROUPS."
.IX Header "USING LDAP GROUPS."
.SS "What are \s-1LDAP\s0 groups?"
.IX Subsection "What are LDAP groups?"
\&\s-1LDAP\s0 groups are object classes that contain an attribute that can
store multiple \s-1DN\s0 values.  Two standard object classes are
\&'groupOfNames' (which has a 'member' attribute) and
\&'groupOfUniqueNames' (which has a 'uniqueMember' attribute.)
.PP
According to the RFCs a group can be a member of another group,
but some \s-1LDAP\s0 server vendors restrict this flexibility by not
allowing nested groups in their servers.
.PP
Two scripts for working with groups are available in the contrib
directory.  They are isMember.pl and printMembers.pl.
.SS "How do you format a filter to search for entries whose 'member' attribute has a particular value?"
.IX Subsection "How do you format a filter to search for entries whose 'member' attribute has a particular value?"
Asking for (member=*) is \s-1OK \-\s0 the directory uses the equality matching
rule which is defined for the member attribute.
.PP
Asking for (member=c*) is not \s-1OK \-\s0 there is no defined substring
matching rule for the member attribute. That's because the member
values are *not* strings, but distinguished names. There is no
substring matching rule for DNs, see \s-1RFC 4519\s0 section 2.7.
.PP
What you have to do is get the results of (member=*) and then select
the required results from the returned values. You need to do this
using knowledge of the string representation of DNs defined in \s-1RFC
4514,\s0 which is important because the same \s-1DN\s0 can have different string
representations. So you need to perform some canonicalization if you
want to be correct.
.SH "USING DSML."
.IX Header "USING DSML."
.SS "How can I access \s-1DSML\s0 features from perl-ldap?"
.IX Subsection "How can I access DSML features from perl-ldap?"
Directory Service Markup Language (\s-1DSML\s0) is the \s-1XML\s0
standard for representing directory service information in
\&\s-1XML.\s0
.PP
Support for \s-1DSML\s0 is included in perl-ldap starting with version
\&.20.
.PP
At the moment this module only reads and writes \s-1DSML\s0 entry
entities. It cannot process any schema entities because
schema entities are processed differently than elements.
.PP
Eventually this module will be a full level 2 consumer and
producer enabling you to give you full \s-1DSML\s0 conformance.
.PP
The specification for \s-1DSML\s0 is at http://www.oasis\-open.org/specs/
.PP
For further information and code examples read the \s-1DSML\s0
module documentation;  perldoc Net::LDAP::DSML
.SH "USING CONTROLS AND VIRTUAL LISTS."
.IX Header "USING CONTROLS AND VIRTUAL LISTS."
.SS "How do I access the Control features?"
.IX Subsection "How do I access the Control features?"
Support for \s-1LDAP\s0 version 3 Control objects is included in
perl-ldap starting with version .20.
.PP
For further information and code examples read the Control
module documentation;  perldoc Net::LDAP::Control
.SS "How do I access the Virtual List features?"
.IX Subsection "How do I access the Virtual List features?"
Support for Virtual Lists is included in perl-ldap starting
with version .20.
.PP
For further information and code examples read the Control
module documentation;  perldoc Net::LDAP::Control
.SH "GENERAL QUESTIONS."
.IX Header "GENERAL QUESTIONS."
.SS "Are there any other code examples."
.IX Subsection "Are there any other code examples."
Yes, there is an Examples pod file.  To view the pod
do the following command;  perldoc Net::LDAP::Examples
.PP
There is user contributed software in the contrib directory
that is supplied with the perl-ldap distribution.  This is an
excellent source of information on how to use the perl-ldap module.
.SS "Are there any performance issues with perl-ldap?"
.IX Subsection "Are there any performance issues with perl-ldap?"
In the vast majority of use cases (one user has suggested 9 out of 10)
there are no performance issues with perl-ldap.
.PP
Where you may wish to use perl-ldap to perform, for example, a very
large number of queries (e.g. 10,000) in succession you may find a
noticeable performance difference between perl-ldap and non pure-Perl
modules. This is not because of perl-ldap itself but because of the
pure-Perl Convert::ASN1 module that it depends on.
.PP
You should make up your own mind, based upon your own situation
(performance requirements, hardware etc.) as to whether you should use
perl-ldap or not. The figures quoted in this answer are only
indicative, and will differ for different people.
.SS "Can I contribute Perl scripts that use perl-ldap to the contrib section?"
.IX Subsection "Can I contribute Perl scripts that use perl-ldap to the contrib section?"
Any one can submit a Perl script that uses perl-ldap for inclusion
in the contrib section.  The perl-ldap maintainers will determiner
if the script will be included and will do the initial check in of
the script to the Git repository at https://github.com/perl\-ldap/perl\-ldap.
.PP
There are a couple of requirements for consideration.
.PP
You must supply a one line description of your script to be included
in the contrib \s-1README\s0 file.
.PP
Inside the script will be the pod documentation for the script.
No auxiliary documentation will be allowed.  For examples of how
to do this see the tklkup script currently in the contrib section.
.SS "Is it possible to get a complete entry, \s-1DN\s0 and attributes without specifying the attributes name?"
.IX Subsection "Is it possible to get a complete entry, DN and attributes without specifying the attributes name?"
Yes, just specify you want a list of no attributes back. The \s-1RFC\s0 says
that this tells the server to return all readable attributes back
(there may be access controls to prevent some from being returned.)
.PP
So in the search method, just set (for LDAPv2):
.PP
.Vb 1
\&                attrs => [ ]
.Ve
.PP
If you are using LDAPv3, you can specify an attribute called \*(L"*\*(R"
instead, which lets you ask for additional (i.g. operational) attributes
in the same search.
.PP
.Vb 1
\&                attrs => [ "*" ]
.Ve
.PP
To get all operational attributes in a search, some servers allow
the use of the \*(L"+\*(R" pseudo attribute. So that with these servers
.PP
.Vb 1
\&                attrs => [ "*", "+" ]
.Ve
.PP
will return the most information from the server.
.SS "How do I put a \s-1JPEG\s0 photo into a entry in the directory?"
.IX Subsection "How do I put a JPEG photo into a entry in the directory?"
Follow the following code example, replacing the (...) with
whatever is relevant to your setup.
.PP
.Vb 3
\&  use Net::LDAP;
\&  use Net::LDAP::Util qw(ldap_error_text);
\&  use CGI;
\&
\&  local $/ = undef;
\&  my $jpeg = <$filename>;
\&
\&  my $ldap = Net::LDAP\->new(...);
\&  my $res = $ldap\->bind(...);
\&     $res = $ldap\->modify(...,
\&                   add => [ \*(AqjpegPhoto\*(Aq => [ $jpeg ] ]);
\&     $res = $ldap\->unbind();
.Ve
.SS "How do I add a jpeg photo into a entry in the directory via html-forms?"
.IX Subsection "How do I add a jpeg photo into a entry in the directory via html-forms?"
Follow the following code example, replacing the (...) with
whatever is relevant to your setup.
.PP
.Vb 3
\&  use Net::LDAP;
\&  use Net::LDAP::Util qw(ldap_error_text);
\&  use CGI;
\&
\&  my $q = new CGI;
\&
\&  print $q\->header;
\&  print $q\->start_html(\-title => \*(AqChange JPEG photo\*(Aq);
\&
\&  if ($q\->param(\*(AqUpdate\*(Aq)) {
\&          my $filename = $q\->param(\*(Aqjpeg\*(Aq);
\&          local $/ = undef;
\&          my $jpeg = <$filename>;
\&
\&          my $ldap = Net::LDAP\->new(...);
\&          my $res = $ldap\->bind(...);
\&          $res = $ldap\->modify(...,
\&                          add => [ \*(AqjpegPhoto\*(Aq => [ $jpeg ] ]);
\&          $res = $ldap\->unbind();
\&  } else {
\&          print $q\->start_multipart_form();
\&          print $q\->filefield(\-name => \*(Aqjpeg\*(Aq, \-size => 50);
\&          print $q\->submit(\*(AqUpdate\*(Aq);
\&          print $q\->end_form();
\&  }
\&
\&  print $q\->end_html();
.Ve
.SS "What happens when you delete an attribute that does not exist?"
.IX Subsection "What happens when you delete an attribute that does not exist?"
It is an error to delete an attribute that doesn't exist.  When you
get the error back the server ignores the entire modify operation
you sent it, so you need to make sure the error doesn't happen.
.PP
Another approach, if you are using LDAPv3 (note beginning with version .27
Net::LDAP uses LDAPv3 by default) is to use a 'replace' with your
attribute name and no values.
In LDAPv3, this is defined to always work even if that attribute
doesn't exist in the entry.
.PP
ie:
.PP
.Vb 1
\&  my $mesg = $ldap\->modify( $entry, replace => { %qv_del_arry } );
.Ve
.PP
But make sure you are using LDAPv3, because that is defined to \fBnot\fR work
in LDAPv2. (A nice incompatibility between LDAPv2 and LDAPv3.)
.SS "How can I delete a referral from an \s-1LDAP\s0 tree?"
.IX Subsection "How can I delete a referral from an LDAP tree?"
Since this is a proprietary feature, you will have to check your
server's documentation. You might find that you need to use a control. If
there is a control called something like ManageDsaIT, that's the one you
should probably use.  For proper operation you will need the oid number
for ManageDsaIT; 2.16.840.1.113730.3.4.2 and do not specify a value for
type.
.PP
The code required will look similar to the following code snippet.
.PP
.Vb 2
\&  $mesg =  $ldap\->delete("ref=\e"ldap://acme/c=us,o=bricks\e",o=clay",
\&                  control => {type => "2.16.840.1.113730.3.4.2"} );
.Ve
.SS "How do I add an \s-1ACI/ACL\s0 entry to a directory server with perl-ldap?"
.IX Subsection "How do I add an ACI/ACL entry to a directory server with perl-ldap?"
ACIs and ACLs are proprietary features in \s-1LDAP.\s0 The following code
snippet works with a Netscape directory server. You will need the
specify the correct \s-1DN \s0(\-DN\-) and correct attribute(s) (\-ATTRNAMEs\-).
.PP
.Vb 2
\&  my $aci = \*(Aq(target="ldap:///\-DN\-")(targetattr="\-ATTRNAMEs\-")(version 3.0;
\&              acl "\-ACLNAME\-"; deny(all) userdn = "ldap:///self";)\*(Aq ;
\&
\&  $ldap\->modify($dn_modif, add => {\*(Aqaci\*(Aq => $aci });
.Ve
.SS "How do I avoid file type and data type mis-matching when loading data from a Win32 system?"
.IX Subsection "How do I avoid file type and data type mis-matching when loading data from a Win32 system?"
When loading a binary attribute with data read from a file on a Win32
system, it has been noted that you should set \*(L"binmode\*(R" on the file
before reading the file contents into the data array.
.PP
Another possible solution to this problem is to convert the
binary data into a base64 encoded string and then store the encoded string
in the file.  Then when reading the file, decode the base64 encoded
string back to binary and then use perl-ldap to store the data
in the directory.
.SS "How do I create an account in Active Directory?"
.IX Subsection "How do I create an account in Active Directory?"
Active Directory accounts need some AD-specific attributes
(only the method we're interested in, no error checking):
.PP
.Vb 12
\&  $mesg = $ldap\->add( \*(Aqcn=John Doe,cn=Users,dc=your,dc=ads,dc=domain\*(Aq,
\&                      attrs => [
\&                        objectClass => [ qw/top user/ ],
\&                        cn => \*(AqJohn Doe\*(Aq,
\&                        sn => \*(AqDoe\*(Aq,
\&                        givenName => \*(AqJohn\*(Aq,
\&                        displayName => \*(AqJohn "the one" Doe\*(Aq,
\&                        userAccountControl => 514,      # disabled regular user
\&                        sAMAccountName => \*(AqJohnDoe\*(Aq,
\&                        userPrincipalName => \*(AqJohnDoe@your.ads.domain\*(Aq
\&                      ]
\&                    );
.Ve
.PP
In order to find out what other attributes can be set, interactively
edit the user in the Active Directory Users and Computers \s-1MCC\s0 plugin,
perform an \s-1LDAP\s0 search operation to find out what changed, and update
your \*(L"add\*(R" routine accordingly.
.SS "How can I create a group in Active Directory?"
.IX Subsection "How can I create a group in Active Directory?"
Similar to accounts, groups need some AD-specific attributes too:
.PP
.Vb 8
\&  $mesg = $ldap\->add( \*(Aqcn=NewGroup,cn=Users,dc=your,dc=ads,dc=domain\*(Aq,
\&                      attrs => [
\&                        objectClass => [ qw/top group/ ],
\&                        cn => \*(AqNewGroup\*(Aq,
\&                        sAMAccountName => \*(AqNewGroup\*(Aq,
\&                        groupType => 0x80000002         # global, security enabled group
\&                      ]
\&                    );
.Ve
.SS "How do I search for disabled accounts in Active Directory"
.IX Subsection "How do I search for disabled accounts in Active Directory"
The bit values in \f(CW\*(C`userAccountControl\*(C'\fR require the \s-1LDAP_MATCHING_RULE_BIT_AND\s0
matching rule's \s-1OID\s0 to be used in an extensible filter term:
.PP
.Vb 5
\&  $mesg = $ldap\->search( base   => \*(Aqcn=Users,dc=your,dc=ads,dc=domain\*(Aq,
\&                         filter => \*(Aq(&(objectclass=user)\*(Aq .
\&                                      (userAccountControl:1.2.840.113556.1.4.803:=2))\*(Aq,
\&                         attrs  => [ \*(Aq1.1\*(Aq ]
\&                       );
.Ve
.SS "How can I search for security groups in Active Directory"
.IX Subsection "How can I search for security groups in Active Directory"
With groups, the same applies to the \f(CW\*(C`groupType\*(C'\fR bit-field:
.PP
.Vb 6
\&  $mesg = $ldap\->search( base   => \*(Aqcn=Users,dc=your,dc=ads,dc=domain\*(Aq,
\&                         filter => \*(Aq(&(objectclass=group)\*(Aq .
\&                                      (groupType:1.2.840.113556.1.4.803:=2147483648))\*(Aq,
\&                                      # 2147483648 = 0x80000000
\&                         attrs  => [ \*(Aq1.1\*(Aq ]
\&                       );
.Ve
.SS "How can I search for all members of a group in \s-1AD \s0(including group nesting)?"
.IX Subsection "How can I search for all members of a group in AD (including group nesting)?"
\&\s-1AD\s0 allows you to find all members of a specified group, the direct members
plus those that are member of the group via group nesting.
.PP
The trick to this is the special \f(CW\*(C`LDAP_MATCHING_RULE_IN_CHAIN\*(C'\fR matching rule:
.PP
.Vb 4
\&  $mesg = $ldap\->search( base   => \*(Aqcn=Users,dc=your,dc=ads,dc=domain\*(Aq,
\&                         filter => \*(Aq(memberOf:1.2.840.113556.1.4.1941:=cn=Testgroup,dc=your,dc=ads,dc=domain)\*(Aq,
\&                         attrs  => [ \*(Aq1.1\*(Aq ]
\&                       );
.Ve
.SS "How can I search for all groups one user is a member of in \s-1AD \s0(including group nesting)?"
.IX Subsection "How can I search for all groups one user is a member of in AD (including group nesting)?"
Similarly you can search for all the groups one user is member of, either directly
or via group nesting.
.PP
.Vb 4
\&  $mesg = $ldap\->search( base   => \*(Aqdc=your,dc=ads,dc=domain\*(Aq,
\&                         filter => \*(Aq(member:1.2.840.113556.1.4.1941:=cn=TestUser,ou=Users,dc=your,dc=ads,dc=domain)\*(Aq,
\&                         attrs  => [ \*(Aq1.1\*(Aq ]
\&                       );
.Ve
.SS "How do I search for all members of a large group in \s-1AD\s0?"
.IX Subsection "How do I search for all members of a large group in AD?"
\&\s-1AD\s0 normally restricts the number of attribute values returned in one query.
The exact number depends on the \s-1AD\s0 server version: it was ~1000 in Win2000,
1500 in Win2003 and is 5000 in Win2008 & Win2008R2.
.PP
Performing the same standard search again will yield the same values again.
.PP
So, how can you get all members of a really large \s-1AD\s0 group?
.PP
The trick to use here is to use Microsoft's \fIrange option\fR when searching,
i.e instead of doing one search for plain \f(CW\*(C`member\*(C'\fR, perform multiple searches
for e.g. \f(CW\*(C`member;range=1000\-*\*(C'\fR where the range starting index increases accordingly:
.PP
.Vb 3
\&  my $mesg;
\&  my @members;
\&  my $index = 0;
\&
\&  while ($index ne \*(Aq*\*(Aq) {
\&    $mesg = $ldap\->search( base   => \*(Aqcn=Testgroup,dc=your,dc=ads,dc=domain\*(Aq,
\&                           filter => \*(Aq(objectclass=group)\*(Aq,
\&                           scope  => \*(Aqbase\*(Aq,
\&                           attrs  => [ ($index > 0) ? "member;range=$index\-*" : \*(Aqmember\*(Aq ]
\&                         );
\&    if ($mesg\->code == LDAP_SUCCESS) {
\&      my $entry = $mesg\->entry(0);
\&      my $attr;
\&
\&      # large group: let\*(Aqs do the range option dance
\&      if (($attr) = grep(/^member;range=/, $entry\->attributes)) {
\&        push(@members, $entry\->get_value($attr));
\&
\&        if ($attr =~ /^member;range=\ed+\-(.*)$/) {
\&          $index = $1;
\&          $index++  if ($index ne \*(Aq*\*(Aq);
\&        }
\&      }
\&      # small group: no need for the range dance
\&      else {
\&        @members = $entry\->get_value(\*(Aqmember\*(Aq);
\&        last;
\&      }
\&    }
\&    # failure
\&    else {
\&      last;
\&    }
\&  }
\&
\&  if ($mesg\->code == LDAP_SUCCESS) {
\&    # success: @members contains the members of the group
\&  }
\&  else {
\&    # failure: deal with the error in $mesg
\&  }
.Ve
.PP
See <http://msdn.microsoft.com/en\-us/library/windows/desktop/aa367017.aspx>
for more details.
.SS "How do I create a Microsoft Exchange 5.x user?"
.IX Subsection "How do I create a Microsoft Exchange 5.x user?"
This is a solution provided by a perl-ldap user.
.PP
This code works with ActiveState Perl running on WinNT 4. Please note that
this requires the Win32::Perms module, and needs valid \s-1NT\s0 account info to
replace the placeholders.
.PP
.Vb 3
\&  use Net::LDAP;
\&  use Net::LDAP::Util;
\&  use Win32::Perms;
\&
\&  #Constants taken from ADSI Type Library
\&  $ADS_RIGHT_EXCH_ADD_CHILD = 1;
\&  $ADS_RIGHT_EXCH_DELETE = 0x10000;
\&  $ADS_RIGHT_EXCH_DS_REPLICATION = 64;
\&  $ADS_RIGHT_EXCH_DS_SEARCH = 256;
\&  $ADS_RIGHT_EXCH_MAIL_ADMIN_AS = 32;
\&  $ADS_RIGHT_EXCH_MAIL_RECEIVE_AS = 16;
\&  $ADS_RIGHT_EXCH_MAIL_SEND_AS = 8;
\&  $ADS_RIGHT_EXCH_MODIFY_ADMIN_ATT = 4;
\&  $ADS_RIGHT_EXCH_MODIFY_SEC_ATT = 128;
\&  $ADS_RIGHT_EXCH_MODIFY_USER_ATT = 2;
\&
\&  $EXCH_USER_RIGHTS = $ADS_RIGHT_EXCH_MAIL_RECEIVE_AS |
\&  $ADS_RIGHT_EXCH_MAIL_SEND_AS |
\&  $ADS_RIGHT_EXCH_MODIFY_USER_ATT;
\&
\&  $exch = Net::LDAP\->new(\*(Aqserver\*(Aq, debug =>0) || die $@;
\&
\&  $exch\->bind( \*(Aqcn=admin_user,cn=nt_domain,cn=admin\*(Aq, version =>3,
\&  password=>\*(Aqpassword\*(Aq);
\&
\&  $myObj = Win32::Perms\->new();
\&  $Result = $myObj\->Owner(\*(Aqnt_domain\euser_name\*(Aq);
\&  $myObj\->Group(\*(Aqnt_domain\eEveryone\*(Aq);
\&  $myObj\->Allow(\*(Aqnt_domain\euser_name\*(Aq,
\&  $EXCH_USER_RIGHTS,OBJECT_INHERIT_ACE);
\&  $BinarySD = $myObj\->GetSD(SD_RELATIVE);
\&  $TextSD = uc(unpack( "H*", $BinarySD ));
\&  Win32::Perms::ResolveSid(\*(Aqnt_domain\euser_name\*(Aq, $sid);
\&  $mysid = uc(unpack("H*",$sid));
\&
\&  $result = $exch\->add ( dn   =>
\&                \*(Aqcn=user_name,cn=container,ou=site,o=organisation\*(Aq,
\&                attr => [ \*(AqobjectClass\*(Aq => [\*(AqorganizationalPerson\*(Aq],
\&                          \*(Aqcn\*(Aq   => \*(Aqdirectory_name\*(Aq,
\&                          \*(Aquid\*(Aq => \*(Aqmail_nickname\*(Aq,
\&                          \*(Aqmail\*(Aq => \*(Aqsmtp_address\*(Aq,
\&                        \*(Aqassoc\-nt\-account\*(Aq => [ $mysid ],
\&                        \*(Aqnt\-security\-descriptor\*(Aq => [ $TextSD ],
\&                        \*(AqmailPreferenceOption\*(Aq  => 0
\&                        ]
\&              );
\&
\&
\&  print ldap_error_name($result\->code);
.Ve
.SS "How do I reset a user's password ..."
.IX Subsection "How do I reset a user's password ..."
\fI... in most \s-1LDAP\s0 servers?\fR
.IX Subsection "... in most LDAP servers?"
.PP
Most \s-1LDAP\s0 servers use the standard userPassword attribute as the
attribute to set when you want to change a user's password.
.PP
They usually allow to set the password either using the regular
modify operation on the userPassword attribute or using the
extended \s-1LDAP\s0 Password Modify operation defined in \s-1RFC3062.\s0
.PP
The recommended method is the extended Password Modify operation,
which offers a standardized way to set user passwords but
unfortunately is not available on all \s-1LDAP\s0 servers.
.PP
Whether the extended Password Modify operation is available can be
found out by searching the attribute supportedExtension for the
value 1.3.6.1.4.1.4203.1.11.1 in the RootDSE object.
.PP
If the extended Password Modify operation is not available the
alternative is the regular modification of the userPassword attribute.
.PP
But this method has some drawbacks:
.IP "\(bu" 4
Depending on the type of the server the arguments to the modify
operations may vary. Some want the modify done with replace,
some want it done by explicitly deleting the old password
and add of the new one.
This may even depend on whether you change the password for the bound
user or as an administrator for another user.
.IP "\(bu" 4
With the modify operation some servers expect the client to
do the hashing of the password on the client side. I.e. all
clients that set passwords need to agree on the algorithm
and the format of the hashed password.
.IP "\(bu" 4
Some \s-1LDAP\s0 servers do not allow setting the password if the
connection is not sufficiently secured. I.e. require \s-1SSL\s0 or \s-1TLS\s0
support to set the password (which is heavily recommended anyway ;\-)
.PP
Here is an example of how to change your own password (for brevity's
sake error checking is left out):
.PP
.Vb 1
\&  use Net::LDAP;
\&
\&  my $ldap = Net::LDAP\->new(\*(Aqldaps://server.domain\*(Aq)  or  die "$@";
\&  my $mesg = $ldap\->bind(\*(Aqcn=Joe User,dc=perl,dc=ldap,dc=org\*(Aq,
\&                         password => \*(AqoldPW\*(Aq);
\&
\&  my $rootdse = $ldap\->root_dse();
\&
\&  if ($rootdse\->supported_extension(\*(Aq1.3.6.1.4.1.4203.1.11.1\*(Aq) {
\&
\&      require Net::LDAP::Extension::SetPassword;
\&
\&      $mesg = $ldap\->set_password(user => \*(Aqcn=Joe User,dc=perl,dc=ldap,dc=org\*(Aq,
\&                                  oldpasswd => \*(AqoldPW\*(Aq,
\&                                  newpasswd => \*(AqnewPW\*(Aq);
\&  }
\&  else {
\&      $mesg = $ldap\->modify(\*(Aqcn=Joe User,dc=perl,dc=ldap,dc=org\*(Aq,
\&                            changes => [
\&                                delete => [ userPassword => $oldPW ]
\&                                add    => [ userPassword => $newPW ] ]);
\&  }
\&
\&  $ldap\->unbind();
.Ve
.PP
\fI... in \s-1MS\s0 Active Directory?\fR
.IX Subsection "... in MS Active Directory?"
.PP
With Active Directory a user's password is stored in the unicodePwd
attribute and changed using the regular modify operation.
.PP
\&\s-1ADS\s0 expects this password to be encoded in Unicode \- \s-1UTF\-16\s0 to be exact.
Before the Unicode conversion is done the password needs to be
surrounded by double quotes which do not belong to the user's password.
.PP
For the password modify operation to succeed \s-1SSL\s0 is required.
.PP
When changing the password for the user bound to the directory
\&\s-1ADS\s0 expects it to be done by deleting the old password and
adding the new one.
When doing it as a user with administrative privileges replacing
the unicodePwd's value with a new one is allowed too.
.PP
Perl-ldap contains convenience methods for Active Directory that
allow one to perform this task very easily.
.PP
Here's an example that demonstrates setting your own password
from \f(CW$oldPW\fR to \f(CW$newPW\fR (again almost no error checking):
.PP
.Vb 2
\&  use Net::LDAP;
\&  use Net::LDAP::Extra qw(AD);
\&
\&  my $ldap = Net::LDAP\->new(\*(Aqldaps://ads.domain.controller\*(Aq)  or  die "$@";
\&
\&  my $mesg = $ldap\->bind(\*(Aqcn=Joe User,dc=your,dc=ads,dc=domain\*(Aq,
\&                         password => $oldPW);
\&
\&  $mesg = $ldap\->change_ADpassword(\*(Aqcn=Joe User,dc=your,dc=ads,dc=domain\*(Aq,
\&                                   $oldPW, $newPW);
\&
\&  $ldap\->unbind();
.Ve
.PP
And the same for perl-ldap versions before 0.49, where everything needs
to be done by hand:
.PP
.Vb 3
\&  use Net::LDAP;
\&  use Unicode::Map8;
\&  use Unicode::String qw(utf16);
\&
\&  # build the conversion map from your local character set to Unicode
\&  my $charmap = Unicode::Map8\->new(\*(Aqlatin1\*(Aq)  or  die;
\&
\&  # surround the PW with double quotes and convert it to UTF\-16
\&  # byteswap() was necessary in experiments on i386 Linux, YMMV
\&  my $oldUniPW = $charmap\->tou(\*(Aq"\*(Aq.$oldPW.\*(Aq"\*(Aq)\->byteswap()\->utf16();
\&  my $newUniPW = $charmap\->tou(\*(Aq"\*(Aq.$newPW.\*(Aq"\*(Aq)\->byteswap()\->utf16();
\&
\&  my $ldap = Net::LDAP\->new(\*(Aqldaps://ads.domain.controller\*(Aq)  or  die "$@";
\&
\&  my $mesg = $ldap\->bind(\*(Aqcn=Joe User,dc=your,dc=ads,dc=domain\*(Aq,
\&                         password => $oldPW);
\&
\&  $mesg = $ldap\->modify(\*(Aqcn=Joe User,dc=your,dc=ads,dc=domain\*(Aq,
\&                        changes => [
\&                            delete => [ unicodePwd => $oldUniPW ]
\&                            add    => [ unicodePwd => $newUniPW ] ]);
\&
\&  $ldap\->unbind();
.Ve
.SS "How can I simulate server failover?"
.IX Subsection "How can I simulate server failover?"
Perl-ldap does not do server failover, however there are several
programming options for getting around this situation.
.PP
Here is one possible solution:
.PP
.Vb 2
\&  $ldaps = Net::LDAPS\->new([ $ldapserverone, $ldapservertwo ],
\&                           port=>636, timeout=>5)  or  die "$@";
.Ve
.PP
For perl-ldap versions before 0.27, the same goal can be achieved using:
.PP
.Vb 9
\&  unless ( $ldaps =
\&            Net::LDAPS\->new($ldapserverone,
\&                            port=>636,timeout=>5) )
\&          {
\&              $ldaps = Net::LDAPS\->new($ldapservertwo,
\&                                       port=>636,timeout=>20) ||
\&              return
\&              "Can\*(Aqt connect to $ldapserverone or $ldapservertwo via LDAPS: $@";
\&          }
.Ve
.SH "Using X.509 certificates."
.IX Header "Using X.509 certificates."
.SS "How do I store X.509 certificates in the directory?"
.IX Subsection "How do I store X.509 certificates in the directory?"
The first problem here is that there are many different formats to hold
certificates in, for example \s-1PEM, DER,\s0 PKCS#7 and PKCS#12. The directory
\&\fBonly\fR uses the \s-1DER\s0 format (more correctly, it only uses the \s-1BER\s0 format)
which is a binary format.
.PP
Your first job is to ensure that your certificates are therefore in \s-1DER/BER\s0
format. You could use OpenSSL to convert from \s-1PEM\s0 like this:
.PP
.Vb 1
\&  openssl x509 \-inform PEM \-in cert.pem \-outform DER \-out cert.der
.Ve
.PP
Consult the OpenSSL documentation to find out how to perform other
conversions.
.PP
To add a certificate to the directory, just slurp in the \s-1DER/BER\s0
certificate into a scalar variable, and add it to the entry's
userCertificate attribute. How you do that will depend on which version of
\&\s-1LDAP\s0 you are using.
.PP
To slurp in the certificate try something like this:
.PP
.Vb 9
\&  my $cert;
\&  {
\&      local $/ = undef; # Slurp mode
\&      open CERT, "cert.der" or die;
\&      binmode CERT;     # for Windows e.a.
\&      $cert = <CERT>;
\&      close CERT;
\&  }
\&  # The certificate is now in $cert
.Ve
.PP
For LDAPv2, because most directory vendors ignore the string representation
of certificates defined in \s-1RFC 1778,\s0 you should add this value to the
directory like this:
.PP
.Vb 6
\&  $res = $ldap\->modify("cn=My User, o=My Company,c=XY",
\&                       add => [
\&                               \*(AquserCertificate\*(Aq => [ $cert ]
\&                              ]);
\&  die "Modify failed (" . ldap_error_name($res\->code) . ")\en"
\&      if $res\->code;
.Ve
.PP
For LDAPv3, you must do this instead:
.PP
.Vb 6
\&  $res = $ldap\->modify("cn=My User, o=My Company, c=XY",
\&                       add => [
\&                               \*(AquserCertificate;binary\*(Aq => [ $cert ]
\&                              ]);
\&  die "Modify failed (" . ldap_error_name($res\->code) . ")\en"
\&      if $res\->code;
.Ve
.PP
Of course, the entry you are trying to add the certificate to must use
object classes that permit the userCertificate attribute, otherwise the
modify will fail with an object class violation error. The inetOrgPerson
structural object class permits userCertificates, as does the
strongAuthenticationUser auxiliary object class. Others might also.
.SS "How do I search objects by the contents of certificates."
.IX Subsection "How do I search objects by the contents of certificates."
The directory needs to support one or more of the certificate*Match
matching rules.
.PP
Then using the filter (for certificateExactMatch)
.PP
.Vb 1
\&  (userCertificate={ serialNumber 1234, issuer "cn=CA,o=TrustCenter" })
.Ve
.PP
allows searching for the objects containing the attribute userCertificate with
a certificate matching these criteria.
.PP
Please note that the exact syntax of the values for the serialNumber and the
issuer above may depend on the \s-1LDAP\s0 server.
In any case the example above works with OpenLDAP 2.4.33.
.SH "ADDITIONAL DIRECTORY AND LDAP RESOURCES."
.IX Header "ADDITIONAL DIRECTORY AND LDAP RESOURCES."
.SS "URLs."
.IX Subsection "URLs."
Net::LDAP::Server \- \s-1LDAP\s0 server framework in Perl
http://search.cpan.org/search?module=Net::LDAP::Server
https://github.com/alexrj/Net\-LDAP\-Server
.PP
Net::LDAP::SimpleServer \- \s-1LDAP\s0 server in Perl
http://search.cpan.org/search?module=Net::LDAP::SimpleServer
https://github.com/russoz/Net\-LDAP\-SimpleServer
.PP
LemonLDAP::NG \- Web SingleSignOn solution & \s-1SAML\s0 IdP in Perl
http://lemonldap\-ng.org/
.PP
Dancer::Plugin::LDAP \- \s-1LDAP\s0 plugin for Dancer micro framework
http://search.cpan.org/search?module=Dancer::Plugin::LDAP
https://github.com/racke/Dancer\-Plugin\-LDAP
.PP
Directory Services Mark Language (\s-1DSML\s0)
http://www.oasis\-open.org/specs/
.PP
eMailman \s-1LDAP\s0 information
http://www.emailman.com/ldap/
.PP
Rafael Corvalan's \s-1LDAP\s0 shell
http://sf.net/projects/ldapsh
.PP
Jeff Hodges's Kings Mountain \s-1LDAP\s0
http://www.kingsmountain.com/ldapRoadmap.shtml
(outdated: last update was in 2004)
.PP
willeke.com's \s-1LDAP\s0 Wiki
http://ldapwiki.willeke.com/wiki/LDAP
.PP
OpenLDAP Directory Server \- open source \s-1LDAP\s0 server.
http://www.openldap.org/
.PP
389 Directory Server \- open source \s-1LDAP\s0 server
http://port389.org/
.PP
ApacheDS \- open source \s-1LDAP\s0 server in Java
http://directory.apache.org/
.PP
CriticalPath
http://www.cp.net/
.PP
ForgeRock's OpenDS \- LDAPv3 server with additional \s-1REST\s0 APIs
http://www.forgerock.com/opendj.html
.PP
\&\s-1IBM\s0 Tivoli Directory Server
http://www\-01.ibm.com/software/tivoli/products/directory\-server/
.PP
Isode (was MessagingDirect)
http://www.isode.com/
.PP
Nexor's X.500 and Internet Directories
http://www.nexor.com/info/directory.htm/
.PP
Novell's eDirectory
http://www.novell.com/
.PP
Octet String
http://www.octetstring.com/
.PP
\&\s-1SUN JAVA JNDI \s0(Java Naming and Directory Interface)
http://java.sun.com/products/jndi/overview.html
.PP
Oracle Directory Server Enterprise Edition, formerly Sun One, formerly iPlanet.
http://www.oracle.com/technetwork/middleware/id\-mgmt/index\-085178.html
.PP
OptimalIDM \- Virtual Identity Server \- .NET \s-1LDAP\s0 virtual directory
http://www.optimalidm.com/products/vis/Virtual\-Directory\-Server\-VDS.aspx
.PP
Quest One Quick Connect Virtual Directory Server \- \s-1LDAP\s0 virtual directory
http://www.quest.com/quest\-one\-quick\-connect\-virtual\-directory\-server/
.PP
UnboundID's Identity data platform
https://www.unboundid.com/
.PP
Virtual Directory Blogger
https://virtualdirectory.wordpress.com/
.PP
eldapo \- a directory manager's blog
http://eldapo.blogspot.de/
.PP
Eine deutsche \s-1LDAP\s0 Website
A german \s-1LDAP\s0 Website
http://verzeichnisdienst.de/ldap/Perl/index.html
.PP
(non-exhaustive) list of \s-1LDAP\s0 software on Wikipedia
http://en.wikipedia.org/wiki/List_of_LDAP_software
.PP
\&\*(L"\s-1RFC\s0 Sourcebook\*(R" on \s-1LDAP\s0
http://www.networksorcery.com/enp/protocol/ldap.htm
.PP
web2ldap \- \s-1WWW\s0 gateway to \s-1LDAP\s0 server in Python
http://www.web2ldap.de/
.PP
Softerra \s-1LDAP\s0 Browser / Administrator
http://www.ldapbrowser.com/
.PP
The 2 following URLs deal mainly with Microsoft's
Active Directory.
.PP
Directory Works
http://directoryworks.com/
.PP
\&\s-1LDAP\s0 Client .Net & ActiveX \s-1LDAP\s0 Client
http://www.ldapservices.com/Products/Default.aspx
.SS "\s-1BOOKS\s0"
.IX Subsection "BOOKS"
Developing \s-1LDAP\s0 and \s-1ADSI\s0 Clients for Microsoft(R) Exchange.
By Sven B. Schreiber.  \s-1ISBN:  0201657775\s0
.PP
Implementing \s-1LDAP.\s0
By Mark Wilcox.  \s-1ISBN:  1861002211\s0
.PP
\&\s-1LDAP:\s0 Programming Directory-Enabled Applications With
Lightweight Directory Access Protocol.
By Tim Howes, Mark Smith.  \s-1ISBN:  1578700000\s0
.PP
\&\s-1LDAP\s0 Programming; Directory Management and Integration.
By Clayton Donley.  \s-1ISBN:  1884777910\s0
.PP
\&\s-1LDAP\s0 Programming with Java.
By Rob Weltman, Tony Dahbura.  \s-1ISBN:  0201657589\s0
.PP
\&\s-1LDAP\s0 System Administration.
By Gerald Carter.  \s-1ISBN:  1565924916\s0
.PP
Managing Enterprise Active Directory Services.
By Robbie Allen, Richard Puckett.  \s-1ISBN:  0672321254\s0
.PP
Solaris and \s-1LDAP\s0 Naming Services.
By Tom Bialaski, Michael Haines. \s-1ISBN:  0\-13\-030678\-9\s0
.PP
Understanding and Deploying \s-1LDAP\s0 Directory Services (2ed).
By Tim Howes, Mark Smith, Gordon Good.
\&\s-1ISBN:  0672323168\s0
.PP
\&\s-1LDAP\s0 Directories Explained.
By Brian Arkills. \s-1ISBN 0\-201\-78792\-X\s0
.SH "AUTHORS"
.IX Header "AUTHORS"
Any good \s-1FAQ\s0 is made up of many authors, everyone that contributes
information to the perl-ldap mail list is a potential author.
.PP
An attempt to maintain this \s-1FAQ\s0 is being done by Chris Ridd
<chris.ridd@isode.com> and Peter Marschall <peter@adpm.de>.
It was previously updated by Clif Harden <charden@pobox.com>.
.PP
The original author of this \s-1FAQ\s0 was Graham Barr <gbarr@pobox.com>
.PP
Please report any bugs, or post any suggestions, to the
perl-ldap mailing list <perl\-ldap@perl.org>.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright (c) 1999\-2004 Graham Barr, (c) 2012 Peter Marschall. All rights reserved.
This document is distributed, and may be redistributed, under the same terms as Perl itself.

Youez - 2016 - github.com/yon3zu
LinuXploit