use Net::LDAP; my $ldap = Net::LDAP->new($ldapServer) or die "Error: $@"; my $success = $ldap->bind($dn, -password => $userPassword); if ($success->code) { print "Error\n"; } else { print "Ok\n"; $ldap->unbind(); }