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

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

有几个这方面的链接:
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

在VyOS路由器上配置访问控制列表(ACL)可以帮助您控制网络流量,提高网络安全性。以下是正确配置VyOS路由器ACL的步骤: 1. 登录VyOS路由器: 首先,通过SSH或控制台登录到您的VyOS路由器。 2. 进入配置模式: 在命令提示符下输入: ``` configure ``` 3. 创建ACL规则: 使用以下命令创建新的ACL规则: ``` set firewall name <ACL_NAME> rule <RULE_NUMBER> action <ACTION> ``` 其中,<ACL_NAME>是您为ACL指定的名称,<RULE_NUMBER>是规则编号(通常从10开始),<ACTION>可以是"accept"(接受)或"drop"(丢弃)。 例如: ``` set firewall name WAN_IN rule 10 action accept ``` 4. 配置匹配条件: 根据需要设置匹配条件,如源地址、目的地址、协议和端口号等。 例如,允许来自特定IP范围(192.168.1.0/24)的SSH访问: ``` set firewall name WAN_IN rule 20 source address 192.168.1.0/24 set firewall name WAN_IN rule 20 destination port 22 set firewall name WAN_IN rule 20 protocol tcp ``` 5. 应用ACL到接口: 使用以下命令将ACL应用到特定的接口和方向: ``` set interfaces ethernet <INTERFACE> firewall in name <ACL_NAME> ``` 或 ``` set interfaces ethernet <INTERFACE> firewall out name <ACL_NAME> ``` 其中,<INTERFACE>是接口名称(如eth0),<ACL_NAME>是您之前创建的ACL名称。 例如,将WAN_IN ACL应用到eth0接口的入站方向: ``` set interfaces ethernet eth0 firewall in name WAN_IN ``` 6. 提交并保存配置: ``` commit save ``` 7. 验证配置: 使用以下命令查看当前的ACL配置: ``` show firewall ``` 注意事项: - 在配置ACL时,请确保不会意外阻止重要的管理访问。 - 始终在远程连接(如SSH)之前配置允许访问的规则,以防被锁定。 - 定期审查和更新ACL,以适应不断变化的网络安全需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值