如何在.net程序中访问 ACL(Access Control List)

本文介绍如何使用C#与.NET2.0进行权限管理,包括通过LDAP路径获取对象权限、设置NTFS权限的方法及示例,并提供测试用户对特定文件访问权限的技术细节。
有几个这方面的链接:
Access Control List in C# 2.0:

Algorithm:

Input:
1. LDAP path of the Object
2. Credentials => UserName and Password

 

Output:
List all the permissions assigned on the give object

 

Algorithm:
1. Bind to the object using the credentials ==> Use DirectoryEntry class for this
2. Get the security information from the object ==> Use ActiveDirectorySecurity class for this
3. Get the Security Descriptor from the security information ==> In SDDL format (basically its a string format)
4. Get all the access rules, access control entries ==> Use AuthorizationRuleCollection class for this
5. For each rule, resolve the SID and object-Type
6. Display all the entries to the user.


Original Link: http://www.codeproject.com/useritems/ADPermissions.asp



To set the NTFS permission of certain file or folder, you may just use WMI
to invoke Win32_LogicalFileSecuritySetting.SetSecurityDescri ptor method to
get this done. There is a sample at:
http://groups.google.com/groups?hl=...8&selm=%23kHUtC
fcCHA.2004%40tkmsftngp12&rnum=2

Also, you may COM interop ADsSecurity.dll, then use SetSecurityDescriptor
method to achieve this. Please refer to:
"HOW TO: Programmatically Set NTFS File System Folder Permissions by Using
Microsoft Visual Basic .NET"
http://support.microsoft.com/defaul...kb;en-us;818362

Yes, WMI may be somewhat slow of retrieving NTFS permissions. You may try
to COM interop ADsSecurity.dll to see if it improves your performance. I
think the article above provides you enough information to get this done.
Also, you may have a try of P/invoke GetSecurityInfo API.


Original Link: http://www.thescripts.com/forum/thread243033.html



还有测试用户对于特定文件的访问权限的:
Testing file access rights in .NET 2.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值