In Active Directory, how do I determine type of ActiveDirectoryAccessRule?
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
}
However, I woul开发者_C百科d 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...
}
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
see
http://msdn.microsoft.com/en-us/library/system.directoryservices.activedirectoryaccessrule.aspx#inheritanceContinued
精彩评论