Handling NTFS permissions, 3 way.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Hi there!
Hopefully someone know what the hell is going wrong.
I'm stuck in setting NTFS permissions. So far I have seen 2 different
methods, how to handle it. (of course I can system('cacls'), but will
try these first.

I'm runing on ActivePerl v.5.8.4 build 810 on Windows XP sp2.

1) Win32::FileSecurity
  Either it does not find an user account, or (seen on documentation) it
may not work for remote files (not tested yet).

use Win32::FileSecurity qw( MakeMask Get Set EnumerateRights );
use Data::Dumper;
use warnings;
use strict;

my $edir = "C:\temp\test";
my $user = "mtjj";

my $dir = MakeMask( qw(  FULL  GENERIC_ALL  ));
my %ace = ();

Get($edir, \%ace) ) {
print ("\n\t Before: \n".Dumper(\%ace));
$ace = $dir;        # user really exist.
#$ace = $dir;    # not work.
#$ace('mtjj@domain.com'} = $dir; # neither this.
Set( $edir, )) {
print ("\n\t After: \n".Dumper(\%ace));

  Program displays Data Dumper Before as it should be, but then:

Error handling error: 1722, LookupAccountName at

and net helpmsgs 1722 says "remote procedure call server is not in use"
(or similiar, I do not have english version windows in this pc).

2) Win32::Perms

use strict;
use warnings;

# install http://perlscript.tlk.fr/perl/packages/Win32-Perms.ppd
use Win32::Perms;

my $dir = "testi";
my $do = new Win32::Perms ( $dir );

  $do->Allow('mtjj', FULL, FILE);
  $do->Allow('mtjj', FULL, DIR);

Result: Can't call method "Allow" on an undefined value at

I copied perms.dll to @inc, and windows system32 dir, but not work.

Suggestions are welcome

Site Timeline