LDAP is lightweight directory access protocol. LDAP is the de-facto Internet directory standard, supported by companies such as Sun, Microsoft, IBM and Novell. LDAP is an integral part of Internet platform offerings like Sun ONE, Microsoft Exchange, and many others.Net::LDAP setup

You can create a perl package or pl file with the following code. package used Net::LDAP

#! /usr/bin/perl
package LdapUser;
use strict;
use Net::LDAPS;
use Net::LDAP;

my $host = "hostname";
my $ldaps = 0;
my $adminDn = "CN=ldpApache,OU=Service Accounts,OU=office loc,OU=Office Locations,DC=northamerica,DC=organization,DC=net";
my $adminPwd = "adminpassword";
my $searchBase = "OU=Office Locations;DC=northamerica;DC=organization;DC=net";
if ($userdn)
{
    print "$userdn checks out!\n";
}
sub getUserDn
{
    my $ldap;
    my $guid = shift;
    my $dn;
    my $entry;

    if ($ldaps) {
        $ldap = Net::LDAPS->new($host, verify=>'none') or die "[email protected]";
    }
    else {
        $ldap = Net::LDAP->new($host, verify=>'none') or die "[email protected]";      
    }
    my $mesg = $ldap->bind ($adminDn, password=>"$adminPwd");
    $mesg->code && return undef;   
    $mesg = $ldap->search(base => $searchBase, filter => "mail=$guid" );     
    $mesg->code && return undef;
    $entry = $mesg->shift_entry;     
    if ($entry)
    {
        $dn = $entry->dn;
        $entry->dump;
    }    
    $ldap->unbind;
    return $dn;
}
sub testGuid
{
    my $ldap;
    my $guid = shift;
    my $userPwd = shift;
    my $userDn = getUserDn ($guid);
    return undef unless $userDn;   
    if ($ldaps) {
        $ldap = Net::LDAPS->new($host, verify=>'none') or die "[email protected]";
    }
    else {
        $ldap = Net::LDAP->new($host, verify=>'none') or die "[email protected]";       
    }
    my $mesg = $ldap->bind ($userDn, password=>"$userPwd");
    
    if ($mesg->code)
    {
        # Bad Bind
        print $mesg->error . "\n";
		print "bad binding";
        return undef;
    }   
    $ldap->unbind;   
    return $userDn;
}

As I have created a package (LdapUser), I am using that package in my code below.

use LdapUser;

my ($userdn, $user_info) = LdapUser->testGuid ("userid", "password");
my @arrayOfDNs  = keys %$user_info;
	foreach ( @arrayOfDNs ) {
		print $_, "\n";
	}

$userdn is the value return if we matched the password else it will be returned as undef.