ActiveDirectoryAccessRule

ActiveDirectoryAccessRule

我可以使用以下代码获取Active Directory对象的访问规则集合:

ActiveDirectorySecurity ads = directoryEntry.ObjectSecurity;
AuthorizationRuleCollection arc = ads.GetAccessRules(true, true, typeof(NTAccount));

foreach (ActiveDirectoryAccessRule adar in arc)
{
    // get rule properties
}


但是,我想知道每个规则是否也是ActiveDirectoryAccessRule子类型之一,例如PropertyAccessRule。

这可能吗?我看不到提供此信息的类属性。

最佳答案

您可以使用is检查类型-例如:

if (adar is System.DirectoryServices.PropertyAccessRule )
{
// do whatever you need to do if it is a PropertyAccessRule...
}


您可以执行以下操作,因为所有继承自ActiveDirectoryAccessRule

System.DirectoryServices.CreateChildAccessRule
System.DirectoryServices.DeleteChildAccessRule
System.DirectoryServices.DeleteTreeAccessRule
System.DirectoryServices.ExtendedRightAccessRule
System.DirectoryServices.ListChildrenAccessRule
System.DirectoryServices.PropertyAccessRule
System.DirectoryServices.PropertySetAccessRule


看到
http://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx#inheritanceContinued

关于c# - 在Active Directory中,如何确定ActiveDirectoryAccessRule的类型?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7032812/

10-15 12:22