# LWP::Protocol::ldap - Provide LDAP support for LWP::UserAgent - perldoc - [phpMan]

## NAME
    [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) - Provide LDAP support for [LWP::UserAgent](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AUserAgent/markdown)

## SYNOPSIS
      use [LWP::UserAgent](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AUserAgent/markdown);

      $ua = [LWP::UserAgent](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AUserAgent/markdown)->new();
      $res = $ua->get('ldap://ldap.example.com/' .
                      'o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)',
                       Accept => 'text/json'):

## DESCRIPTION
    The [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) module provides support for using *ldap* schemed URLs following RFC 4516
    with LWP. This module is a plug-in to the LWP protocol handling, so you don't use it directly.

    In addition to being used with LDAP URIs, [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) also acts as the base class for
    its sibling modules [LWP::Protocol::ldaps](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldaps/markdown) and [LWP::Protocol::ldapi](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldapi/markdown).

### Features
   HTTP methods supported
    [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) implements the HTTP *GET* and *HEAD* methods. They are mapped to the LDAP
    search operation,

   Response format
    Depending on the HTTP *Accept* header provided by the user agent, [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) can answer
    the requests in one of the following formats:

    DSML
        When the HTTP *Accept* header contains the "text/dsml" MIME type, the response is sent as
        DSMLv1.

    JSON
        When the HTTP *Accept* header contains the "text/json" MIME type, the response is sent as
        JSON. For this to work the *JSON* Perl module needs to be installed.

    LDIF
        When the HTTP *Accept* header contains the "text/ldif" MIME type, the response is sent in
        LDIFv1 format.

    HTML
        In case no HTTP *Accept* header has been sent or none of the above MIME types can be
        detected, and the *x-format* extension has not been provided either, the response is sent
        using HTML markup in a 2-column table format (roughly modeled on LDIF).

    As an alternative to sending an HTTP *Accept* header, [LWP::Protocol::ldap](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldap/markdown) also accepts the
    "x-format" extension

    Example:

     ldap://ldap.example.com/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)?x-format=dsml

   TLS support
    For *ldap* and *ldapi* URIs, the module implements the "x-tls" extension that switches the LDAP
    connection to TLS using a call of the start_tls method.

    Example:

     ldap://ldap.example.com/o=University%20of%20Michigan,c=US??sub?(cn=Babs%20Jensen)?x-tls=1

    Note: In the above example, ideally giving "x-tls" should be sufficient, but unfortunately the
    parser in [URI::ldap](https://www.chedong.com/phpMan.php/perldoc/URI%3A%3Aldap/markdown) has a little flaw.

   Authorization
    Usually the connection is done anonymously, but if the HTTP *Authorization* header is provided
    with credentials for HTTP Basic authorization, the credentials given in that header will be used
    to do a simple bind to the LDAP server.

## SEE ALSO
    [LWP::Protocol::ldaps](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldaps/markdown), [LWP::Protocol::ldapi](https://www.chedong.com/phpMan.php/perldoc/LWP%3A%3AProtocol%3A%3Aldapi/markdown)

## COPYRIGHT
    Copyright (c) 1998-2004 Graham Barr, 2012 Peter Marschall. All rights reserved. This program is
    free software; you can redistribute it and/or modify it under the same terms as Perl itself.

