Hi Thomas:

        Here is code snippet from one of my scripts that sets the NTFS permissions
on a user's HOME directory to (RX)(RX) for the user, while removing a group
that I didn't want to have access:

$Path = 'dir:' . "\\\\Server\\Home\\$UserName";

$PermDirFlag = DIRECTORY;
$PermDirMask = READ | EXECUTE;

$PermFileFlag = FILE;
$PermFileMask = READ | EXECUTE;

$HomeDir = new Win32::Perms($Path) ||
        warn "Cannot create new permissions object: $!\n";

# this sets the user's directory permissions
$HomeDir->Allow($UserName, $PermDirMask, $PermDirFlag);

# this sets the user's file permissions within the above directory
$HomeDir->Allow($UserName, $PermFileMask, $PermFileFlag);

# this removes a group's permissions
$HomeDir->Remove("Group"); # only the user should have access.

# this applies the above permissions to the object
$HomeDir->Set();


        I make no claims about the elegance (or lack, thereof) of this code, but,
hey, it works. :)  Also, since I'm new to Perl, my explanations my not be
100% technically correct.  Nevertheless, like I said, the above code works
for me.  I hope this helps.


Dean Theophilou
Genisar

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Thomas Schmidt
Sent: Wednesday, August 15, 2001 4:55 AM
To: [EMAIL PROTECTED]
Subject: Win32-Perm - Question


Hello,

I am triing to set File- and Directory-Permissions with Dave Roth�s
Win32::Perm - Module. The following script sets an ACL to the file
test.txt correctly.
But the sript dont�t work with the directory "c:/temp".
The ReadMe file says, that I have to use a Prefix with the directorys
path, but I dont know the correct way.

Thanks for your help.
Thomas



use Win32::Perms;

 $File = new Win32::Perms;    # Create empty ACL�s
 $Dir  = new Win32::Perms;

 $File->Add({Account=>'co', Mask=>READ});     # Add an account to the
ACL
 $File->Set("c:/tmp-rechte/test.txt");                         # Set the
file's permissions


# the files ACLs are modified correctly
 $Dir->Add({Account=>'co', Mask=>READ});
 $Dir->Set("c:/temp");

# the directories ACLs are not modified




_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to