本文介绍了如何在Perl中修改Windows NTFS权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Server 2003上使用ActiveState Perl.

I'm using ActiveState Perl on Windows Server 2003.

我想在Windows NTFS分区上创建目录,然后授予Windows NT安全组对该文件夹的读取访问权限.在Perl中有可能吗?我必须使用Windows NT命令还是有Perl模块来执行此操作?

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!

推荐答案

标准方法是使用 Win32 :: FileSecurity 模块:

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 ) ) });

请注意,Set将覆盖该目录的权限.如果要编辑现有权限,则需要先Get权限:

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);

这篇关于如何在Perl中修改Windows NTFS权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 01:26