GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Config::Parser::ldap(3) User Contributed Perl Documentation Config::Parser::ldap(3)

Config::Parser::ldap - configuration file parser for ldap.conf

    $cfg = new Config::Parser::ldap($filename);

    $base = $cfg->get('base');

A parser for ldap.conf and similar files.

The syntax of ldap.conf configuration file is very simple. Each statement occupies one physical line and consists of a keyword and its value separated by one or more space characters. Keywords are case-insensitive. A value starts with the first non-blank character after the keyword, and terminates at the end of the line, or at the last sequence of blanks before the end of the line.

Blank lines and lines beginning with a hash mark are ignored.

Parses the supplied configuration file and creates a new object for manipulating its settings. Keyword arguments %opts are:
filename
Name of the file to parse. The file must exist.
line
Optional line where the configuration starts in $filename. It is used to keep track of statement location in the file for correct diagnostics. If not supplied, 1 is assumed.
fh
File handle to read from. If it is not supplied, new handle will be created by using open on the supplied $filename.
lexicon
Dictionary of configuration statements that are allowed in the file. You will most probably not need this parameter. It is listed here for completeness sake. Refer to the Config::AST constructor for details.

All methods for accessing the configuration settings are inherited from Config::AST.

If you wish to use this class as a base class, please refer to Config::Parser for implementation details.

The following simplified example shows how to use this module to connect and bind to a LDAP server.

    use Config::Parser::ldap;
    use Net::LDAP;

    # Parse configuration file
    $cf = new Config::Parser::ldap(filename => '/etc/ldap.conf');

    # Connect to server.
    $ldap = Net::LDAP->new($cf->uri->value);

    # Start TLS if required
    $args{capath} = $cf->get('tls_cacertdir');
    $args{cafile} = $cf->get('tls_cacert');
    $args{clientcert} = $cf->get('tls_cert');
    $args{clientkey} = $cf->get('tls_key');
    $args{ciphers} = $cf->get('tls_cipher_suite');
    if ($reqcert = $cf->get('tls_reqcert')) {
        my %tab = (
            none => 'never',
            allow => 'optional',
            demand => 'require',
            hard => 'require',
            try => 'optional'
        );
        $args{verify} = $tab{$reqcert}
            or die "unrecognized tls_reqcert: $reqcert";
    }
    $mesg = $ldap->start_tls(%args);
    $mesg->code && die $mesg->error;

    # Bind
    @bindargs = ();
    if (my $v = $cf->get('binddn')) {
        push @bindargs, $v
    }
    if (my $v = $cf->get('bindpw')) {
        push @bindargs, password => $v;
    }
    $mesg = $ldap->bind(@bindargs);
    $mesg->code && die $mesg->error;

Config::AST.

Config::Parser.

2021-02-13 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.