#!/usr/bin/perl
use strict;
use warnings;
use Net::LDAP;

my $ldap_host;
my $ldap_port;
my $bind_ldap;
my $status_flag;
my $modus_operandi = "Usage du programme \n \t./check_bind_ldap --host hostname$";

$ldap_host = $ARGV["1"];
$ldap_port = $ARGV["3"];

if (@ARGV){
  $bind_ldap = Net::LDAP->new($ldap_host, port => $ldap_port);
  if($bind_ldap){
    print "Ldap Server Is Running\n";
    $status_flag = 0;
  }
  else {
    print "Ldap Server Is Down\n";
    $status_flag = 2;
  }
  exit($status_flag);
  }

else {
  print $modus_operandi;
  exit 255;
}

