显示或修改指定文件中的任意访问控制列表(DACL),并将存储的 DACL 应用于指定目录中的文件。
Note
This command replaces the deprecated cacls command.
Syntax
icacls name [/save aclfile] [/setowner user] [/findsid Sid] [/verify] [/reset] [/T] [/C] [/L] [/Q]
icacls name [/grant[:r] Sid:perm[...]] [/deny Sid:perm [...]] [/remove[:g|:d]] Sid[...]]] [/setintegritylevel Level:policy[...]] [/T] [/C] [/L] [/Q]
icacls directory [/substitute SidOld SidNew [...]] [/restore aclfile] [/C] [/L] [/Q]
Parameters
Parameter | Description |
---|---|
<name> |
指定要为其显示或修改 DACL 的文件。 |
<directory> |
指定要显示或修改 DACL 的目录。 |
/t | 对当前目录及其子目录中的所有指定文件执行该作。 |
/c | 即使发生文件错误,也会继续该作。 仍然显示错误消息。 |
/l | 对符号链接执行作,而不是对目标执行作。 |
/q | 取消成功消息。 |
/救 <ACLfile> |
将所有匹配文件的 DACL 存储到访问控制列表 (ACL) 文件中,以供稍后使用 /restore 。 |
/setowner <user> |
将所有匹配文件的所有者更改为指定用户。 |
/findsid <sid> |
查找包含显式提及指定安全标识符 (SID) 的 DACL 的所有匹配文件。 |
/verify | 查找具有非规范或长度与访问控制项(ACE)计数不一致的所有文件。 |
/reset | 将 ACL 替换为所有匹配文件的默认继承 ACL。 |
/grant[:r] <sid> :<perm> |
授予指定的用户访问权限。 权限替换以前授予的显式权限。 Not adding :r means that permissions are added to any previously granted explicit permissions. |
/deny <sid> :<perm> |
显式拒绝指定的用户访问权限。 为有状态权限添加显式拒绝 ACE,并删除任何显式授予中的相同权限。 |
/remove: g |d <sid> |
从 DACL 中删除指定 SID 的所有匹配项。 此命令还可以使用: |
/setintegritylevel <perm><level> |
将完整性 ACE 显式添加到所有匹配的文件。 可以将级别指定为: 完整性 ACE 的继承选项可能位于级别之前,并且仅应用于目录。 |
/替代 <sidold> <sidnew> |
Replaces an existing SID (sidold) with a new SID (sidnew). 需要使用 <directory> 参数。 |
/restore <ACLfile> /c | /l | /q |
将存储的 DACL 从 <ACLfile> 应用于指定目录中的文件。 需要使用 <directory> 参数。 |
/inheritancelevel: e |d |r | 设置继承级别,可以是: |
Remarks
SID 可以采用数字或友好名称形式。 如果使用数字形式,将通配符 * 附加到 SID 的开头。
此命令将 ACE 条目的规范顺序保留为:
Explicit denials
Explicit grants
Inherited denials
Inherited grants
此选项
<perm>
是一个权限掩码,可为基本权限、高级权限或继承权限指定:一系列简单权限(基本权限),无需使用括号:
- N - No access
- F - Full access
- M - Modify access
- RX - Read and execute access
- R - Read-only access
- W - Write-only access
- D - Delete access
必须使用括号的特定权限(高级权限)的逗号分隔列表:
- DE - Delete
- RC - Read control (read permissions)
- WDAC - Write DAC (change permissions)
- WO - Write owner (take ownership)
- S - Synchronize
- AS - Access system security
- MA - Maximum allowed
- GR - Generic read
- GW - Generic write
- GE - Generic execute
- GA - Generic all
- RD - Read data/list directory
- WD - Write data/add file
- AD - Append data/add subdirectory
- REA - Read extended attributes
- WEA - Write extended attributes
- X - Execute/traverse
- DC - Delete child
- RA - Read attributes
- WA - Write attributes
必须使用括号的继承权限序列:
- (I) - Inherit. ACE 继承自父容器。
- (OI) - Object inherit. 此容器中的对象继承此 ACE。 仅适用于目录。
- (CI) - Container inherit. 此父容器中的容器继承此 ACE。 仅适用于目录。
- (IO) - Inherit only. ACE 继承自父容器,但不适用于对象本身。 仅适用于目录。
- (NP) - Don't propagate inherit. ACE 由容器和对象从父容器继承,但不会传播到嵌套容器。 仅适用于目录。
Examples
若要将 C:\Windows 目录中的所有文件的 DACL 及其子目录保存到 ACLFile 文件,请键入:
icacls c:\windows\* /save aclfile /t
若要为 C:\Windows 目录及其子目录中存在的 ACLFile 中的每个文件还原 DACL,请键入:
icacls c:\windows\ /restore aclfile
若要向用户授予对名为 Test1 的文件的 Delete 和 Write DAC 权限,请键入:
icacls test1 /grant User1:(d,wdac)
若要向 SID S-1-1-0 定义的用户授予对名为 TestFile 的文件的删除和写入 DAC 权限,请键入:
icacls TestFile /grant *S-1-1-0:(d,wdac)
To apply a high integrity level to a directory and ensure that both its files and subdirectories inherit this level, type:
icacls "myDirectory" /setintegritylevel (CI)(OI)H