#!/usr/bin/perl
#------------------------------------------------------------
#This action resets certain Samba defaults.  This action is
#necessary because these settings may remain to previous 
#domain settings in the situation where we are re-provistioning 
#the domain.  
#
#Copyright 2014 Koozali Foundation, Inc.
#11/22/2014: G.Zartman <gzartman@koozali.org>
#
#The code contained herein can be distributed under the same
#license as Perl
#
#TO DO:
#
#------------------------------------------------------------
package esmith::thisaction;

use strict;
use warnings;

##Pull arguments
my $event = $ARGV [0];
my $AdminPass = $ARGV [1];

die 'Active Directory access error: Missing admin password' unless ($AdminPass);

##Disable the Samba password policy using samba-tool
warn "Samba domain:  Resetting sysvol ACLs to default\n";

my $samba_tool = "/usr/bin/samba-tool ntacl sysvolreset " .
                  "-U Administrator\%$AdminPass";
system ($samba_tool);
die "Samba domain error: Unable to reset sysvol ACLs to default.\n" if ($? == -1);

exit(0);
