简体   繁体   English

使用C#检索和设置NTFS权限

[英]retrieve and set NTFS permissions using c#

I m confused how can I retrieve and set the NTFS permission for a directory using c# 我很困惑如何使用c#检索和设置目录的NTFS权限

such as Save file Stream and save file security 例如保存file Stream并保存file security

I'm looking for how can I save those properties for an executable so that it's stream cannot be modified. 我正在寻找如何保存可执行文件的那些属性,以使其无法修改的流。

System.Security.AccessControl.FileSecurity would be the place to start. System.Security.AccessControl.FileSecurity将是开始的地方。

See the example on that page using File.GetAccessControl method to get an instance. 请参阅该页File.GetAccessControl的示例,使用File.GetAccessControl方法获取实例。

NB. 注意

it's stream cannot be modified . 它的流无法修改。

ACLs can always be overridden (not least my anyone with the Take Ownership privilege: as all local administrators have). ACL始终可以被覆盖(尤其是我拥有“拥有所有权”特权的任何人:就像所有本地管理员一样)。 If you want to ensure an exe is not modified you would be better looking at code signing. 如果要确保未修改exe,最好查看代码签名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM