#!/usr/bin/perl -w

#------------------------------------------------------------
#This action disables an Active Directory user
#
#Command format:
#
# user-AD-disable event username  
#
#  event    : calling event name
#  username : username to disable
#
#Copyright 2016 Koozali Foundation, Inc.
#06/26/2016: G.Zartman <gzartman@koozali.org>
#
#The code contained herein can be distributed under the same
#license as Perl
#
#------------------------------------------------------------
package esmith::thisaction;

use strict;
use warnings;
no warnings ('qw');

##Pull arguments
my $event       = $ARGV [0] || '';
my $userName    = $ARGV [1] || '';

die "username not found in action arguments.`\n"
  unless ($userName);

my $disableUser = '/usr/bin/samba-tool user disable ' . $userName;
system ($disableUser);
die "Unable to disable user $userName.\n" if ($? == -1);

exit(0);
