In Active Directory, how to determine the type of ActiveDirectoryAccessRule?

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

ActiveDirectorySecurity ads = directoryEntry.ObjectSecurity; AuthorizationRuleCollection arc = ads.GetAccessRules(true, true, typeof(NTAccount)); foreach (ActiveDirectoryAccessRule adar in arc) { // get rule properties } 

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

Is it possible? I do not see the properties of the class that provides this information.

+3
source share
1 answer

you can use is to type check - for example:

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

you can do this with the following because everyone inherits from an ActiveDirectoryAccessRule :

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

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

+1
source

All Articles