How can I modify Windows NTFS permissions in Perl?

I'm using ActiveState Perl on Windows Server 2003.

I want to create a directory on a Windows NTFS partition and then grant a Windows NT security group read access to the folder. Is this possible in Perl? Would I have to use Windows NT commands or is there a Perl module to do it?

A small example would be much appreciated!

Answers


The standard way is to use the Win32::FileSecurity module:

use Win32::FileSecurity qw(Set MakeMask);

my $dir = 'c:/newdir';
mkdir $dir or die $!;
Set($dir, { 'Power Users' 
            => MakeMask( qw( READ GENERIC_READ GENERIC_EXECUTE ) ) });

Note that Set will overwrite the permissions for that directory. If you want to edit the existing permissions, you'd need to Get them first:

my %permissions;
Win32::FileSecurity::Get($dir, \%permissions);
$permissions{'Power Users'}
  = MakeMask( qw( READ GENERIC_READ GENERIC_EXECUTE ) ) });
Win32::FileSecurity::Set($dir, \%permissions);

Need Your Help

HTML Position Issue in Firefox (Works in IE and Chrome)

javascript jquery asp.net html css

I have the following code. When I mouse over the “CODE” it should show the div on position 100 X100. It is working fine in IE and Chrome; however the div does not move to the required position in

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.