Handling NTFS permissions, 3 way.

M

mtjjarvin

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{'mtjj'} = $dir; # user really exist.
#$ace{'bigboss\mtjj'} = $dir; # not work.
#$ace('(e-mail address removed)'} = $dir; # neither this.
Set( $edir, {%ace} )) {
print ("\n\t After: \n".Dumper(\%ace));


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

Error handling error: 1722, LookupAccountName at
D:\Perl\tests\Win32Perms5.pl...

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);
$do->Set;

Result: Can't call method "Allow" on an undefined value at
D:\Perl\omat\ad\Win32perms4.pl...

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


Suggestions are welcome
~mtjj~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top