[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#4428) OPenldap proxycache issue with binding



# Perl script to reproduce the behavior
# Written by Michael Donnelly

# Edit $uri, $dn, and $goodpw below to suit your environment.

use Net::LDAP;
use Net::LDAPS;
use Net::LDAP::Extra;
use strict;

my $uri = "ldap://127.0.0.1";;           # Connect local proxycache
#my $uri = "ldap://remote";;             # Connect remote LDAP server

my $dn = "uid=test,ou=people,dc=mydomain,dc=com";
my $goodpw = "321321";          # provide good password here
my $badpw = "bad-password";

my ($LDAP,$result,$error);

$LDAP = Net::LDAP->new($uri);
if (! $LDAP)
{
        die ("Error: Unable to connect to directory $uri\n");
}

print "Testing with bad password: ";
$result = $LDAP->bind(dn => $dn,
        password => $badpw,
        version => 3 );
ShowResults($result);

print "Testing with good password: ";
$result = $LDAP->bind(dn => $dn,
        password => $goodpw,
        version => 3 );
ShowResults($result);

exit;

sub ShowResults
{
        my ($result) = @_;
        if ($result->code)
        {
                print "Error # ". $result->code .  " connecting to $uri as $dn -- " .  $result->error . "\n";
        }
        else
        {
                print "Connection successful\n";
        }
}