ActiveDirectoryAccessRule

ActiveDirectoryAccessRule

本文介绍了在Active Directory中,如何确定ActiveDirectoryAccessRule的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以用code获得的访问规则的集合的Active Directory对象,如

I can get a collection of access rules for an Active Directory object using code such as

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

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

不过,我想知道,如果每个规则也是ActiveDirectoryAccessRule亚型,如PropertyAccessRule之​​一。

However, I would like to know if each rule is also of one of the ActiveDirectoryAccessRule subtypes such as PropertyAccessRule.

这可能吗?我没有看到一个类属性,提供这些信息。

Is this possible? I don't see a class property that provides this information.

推荐答案

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

you can use is to check for the type - for example:

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

你可以用下面的,因为所有的 ActiveDirectoryAccessRule 继承:

you can do this with the following because all inherit from 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

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

这篇关于在Active Directory中,如何确定ActiveDirectoryAccessRule的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 12:02