windows下有效的文件权限工具的api
从 Windows Server 2003 开始,Windows 包含了一个新工具,用于计算用户的有效权限(基本上它解析所有组访问并处理所有“拒绝”权限)。举个例子,用户A属于组B和C。B被拒绝对文件F的读取权限,而C被允许对该文件的读写权限,我想计算用户A拥有的有效权限在文件 F 上。
此工具可在 Windows Server 2003、Vista、7 和 Server 2008 上使用,方法是右键单击文件并转至“属性”->“属性”。安全->高级->有效的权限。
我需要的是 C# 中的 API 来完成相同的工作。最常见的 FILE API 返回访问规则(FileAccessRules 类),但似乎没有直接的方法可以从这些访问规则集计算有效权限。
注意:如果可能的话,我不想在代码中处理有效权限,但我准备这样做作为最后的手段。
Starting from Windows Server 2003, Windows included a new tool which calculates the effective permissions for a user (basically it resolves all groups access and takes care of all "deny" permissions as well). An example in point is that a user A belongs to groups B and C. B has been denied read permissions on a file F, while C has been allowed read and write permissions on the file and I want to calculate the effective permissions user A has on file F.
This tool is available on Windows Server 2003,Vista,7 and Server 2008 by right clicking on a file and going to properties -> security -> advanced -> effective permissions.
What I need is an API in C# which does the same job. The most common FILE API returns access rules (class FileAccessRules), but there seems to be no direct way to calculate effective permissions from these set of access rules.
Note: I do not want to process effective permissions in the code if at all possible, but am ready to do so as a last resort.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一些快速代码:
Some quick code:
我在advapi32.dll中发现了一个名为GetEffectiveRightsFromAcl的函数。这似乎正是我一直在寻找的东西。
实际上,有效的权限工具使用AuthzAccessCheck函数。我使用了它,并没有发现性能下降得像我想象的那么严重。 (但是,我被告知 Authz 不包括 Windows 7 及更高版本中可用的“完整性”概念,并且可能会报告错误的结果。)
I found a function called GetEffectiveRightsFromAcl in advapi32.dll. This seems to be exactly what I was looking for.
Actually, the effective permissions tool uses the AuthzAccessCheck function. I used it, and did not find performance degradation by as much as I thought. (However, I am told that Authz does not include the "integrity" concept available in windows 7 and above, and may report wrong results.)
您可以使用Windows提供的Authz API来确定用户对文件/文件夹的有效权限。
请点击以下链接。
https://msdn.microsoft .com/en-us/library/windows/desktop/ff394768(v=vs.85).aspx 还有这个。 https://msdn.microsoft .com/en-us/library/windows/desktop/aa446637(v=vs.85).aspx。我已经在从 Windows Server 2003 开始的所有 Windows 版本中尝试过此方法,并获得了相当不错的性能。
You can determine the effective permission of an user over a file/folder by using the Authz API provided by Windows.
Follow the below link.
https://msdn.microsoft.com/en-us/library/windows/desktop/ff394768(v=vs.85).aspx and also this. https://msdn.microsoft.com/en-us/library/windows/desktop/aa446637(v=vs.85).aspx. I have tried this out in all versions of Windows starting from Windows server 2003 and got fairly good performance.