#!%PERL% -w 


use strict;

use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Main;
use Vhffs::Services::DNS;
use Vhffs::Acl;

my $princ = init Vhffs::Main;

die("Usage: $0 domain user level\n") unless(@ARGV == 3);

my ($domain, $username, $level) = @ARGV;

my $dns = Vhffs::Services::DNS::get_by_domainname($princ , $domain);
die("Domain $domain not found\n") unless(defined $dns);

my $user = Vhffs::User::get_by_username($princ, $username);
die("User $username not found\n") unless(defined $user);

Vhffs::Acl::add_acl($user, $dns, $level, $princ);

print "User $username has now access level $level domain $domain\n";
