API Reference
ACL
Provides helpers for working with Active Directory ACLs.
Inheritance
- Object
- ACL
Methods
public static Void AddAdAcl(DirectoryEntry entry, AclEntry aclEntry) #VoidAdds the specified ACL entry to a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- entry ADPlayground.Acl.AclEntry
- The ACL entry to add.
public static Void AddAdAcl(ActiveDirectorySecurity security, IdentityInfo identity, AclRights rights, AccessControlType controlType, AclInheritance inheritance) #VoidAdds the specified ACL entry to a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity whose SID will be used.
- rights ADPlayground.Acl.AclRights
- The rights to assign.
- controlType System.Security.AccessControl.AccessControlType
- Allow or deny.
- inheritance ADPlayground.Acl.AclInheritance
- Inheritance settings.
AddAdAcl(System.DirectoryServices.DirectoryEntry entry, ADPlayground.Acl.AclEntry aclEntry) #Adds the specified ACL entry to a directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- aclEntry ADPlayground.Acl.AclEntry
- The ACL entry to add.
public static Void AddAdAclAuditRule(DirectoryEntry entry, IdentityInfo identity, AclRights rights, AuditFlags flags, AclInheritance inheritance) #VoidAdds an audit rule to the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- sid System.String
- The SID to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
AddAdAclAuditRule(System.DirectoryServices.ActiveDirectorySecurity security, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Adds an audit rule to the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
AddAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, System.String sid, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Adds an audit rule to the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- sid System.String
- The SID to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
AddAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Adds an audit rule to the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
public static Void ApplyAdAclChanges(DirectoryEntry entry, Nullable<AclChangeSet> changes) #VoidApplies ACL changes to the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- changes System.Nullable{ADPlayground.Acl.AclChangeSet}
- The change set to apply.
ApplyAdAclChanges(System.DirectoryServices.DirectoryEntry entry, System.Nullable{ADPlayground.Acl.AclChangeSet} changes) #Applies ACL changes to the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- changes System.Nullable{ADPlayground.Acl.AclChangeSet}
- The change set to apply.
public static Void DisableAdAclInheritance(DirectoryEntry entry, Boolean removeInheritedAccessRules) #VoidDisables ACL inheritance for the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- removeInheritedAccessRules System.Boolean
- Whether to remove inherited rules.
DisableAdAclInheritance(System.DirectoryServices.DirectoryEntry entry, System.Boolean removeInheritedAccessRules) #Disables ACL inheritance for the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- removeInheritedAccessRules System.Boolean
- Whether to remove inherited rules.
public static Void EnableAdAclInheritance(DirectoryEntry entry) #VoidEnables ACL inheritance for the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
EnableAdAclInheritance(System.DirectoryServices.DirectoryEntry entry) #Enables ACL inheritance for the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
public static AclInfo GetAdAcl(DirectoryEntry entry) #AclInfoGets ACL information from the provided ActiveDirectorySecurity instance.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to read.
Returns
The ACL information, including owner and access entries.
Examples
Retrieve ACL from an existing directory entry.
using DirectoryEntry entry = new("LDAP://CN=Users,DC=example,DC=com");
AclInfo acl = ACL.GetAdAcl(entry);
GetAdAcl(System.DirectoryServices.DirectoryEntry entry) #Gets ACL information from the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry whose ACL will be read.
Returns
The ACL information for the directory entry.
public static AclChangeSet GetAdAclChanges(DirectoryEntry entry, IEnumerable<AclEntry> desiredEntries) #AclChangeSetComputes changes required to match the desired ACL entries on a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The current security descriptor.
- desiredEntries System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry}
- The desired set of ACL entries.
Returns
A change set describing entries to add and remove.
GetAdAclChanges(System.DirectoryServices.DirectoryEntry entry, System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry} desiredEntries) #Computes ACL changes for the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to compare.
- desiredEntries System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry}
- The desired set of ACL entries.
Returns
A change set describing entries to add and remove.
public static AclOwnerInfo GetAdAclOwner(DirectoryEntry entry) #AclOwnerInfoGets information about the owner of the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to inspect.
Returns
Owner information for the security descriptor.
GetAdAclOwner(System.DirectoryServices.DirectoryEntry entry) #Gets the owner information for the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to inspect.
Returns
Owner information for the directory entry.
public static Void RemoveAdAcl(DirectoryEntry entry, IdentityInfo identity, AclRights rights, AccessControlType controlType, AclInheritance inheritance) #VoidRemoves the specified ACL entry from a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- sid System.String
- The SID to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the entry.
- controlType System.Security.AccessControl.AccessControlType
- The access control type of the entry.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the entry.
RemoveAdAcl(System.DirectoryServices.ActiveDirectorySecurity security, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AccessControlType controlType, ADPlayground.Acl.AclInheritance inheritance) #Removes the specified ACL entry from a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the entry.
- controlType System.Security.AccessControl.AccessControlType
- The access control type of the entry.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the entry.
RemoveAdAcl(System.DirectoryServices.DirectoryEntry entry, System.String sid, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AccessControlType controlType, ADPlayground.Acl.AclInheritance inheritance) #Removes the specified ACL entry from a directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- sid System.String
- The SID to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the entry.
- controlType System.Security.AccessControl.AccessControlType
- The access control type of the entry.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the entry.
RemoveAdAcl(System.DirectoryServices.DirectoryEntry entry, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AccessControlType controlType, ADPlayground.Acl.AclInheritance inheritance) #Removes the specified ACL entry from a directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the entry.
- controlType System.Security.AccessControl.AccessControlType
- The access control type of the entry.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the entry.
public static Void RemoveAdAclAuditRule(DirectoryEntry entry, IdentityInfo identity, AclRights rights, AuditFlags flags, AclInheritance inheritance) #VoidRemoves an audit rule from the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- sid System.String
- The SID to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the rule.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to match.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
RemoveAdAclAuditRule(System.DirectoryServices.ActiveDirectorySecurity security, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Removes an audit rule from the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity whose rule will be removed.
- rights ADPlayground.Acl.AclRights
- The rights associated with the rule.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to match.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
RemoveAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, System.String sid, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Removes an audit rule from the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- sid System.String
- The SID to remove.
- rights ADPlayground.Acl.AclRights
- The rights associated with the rule.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to match.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
RemoveAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Removes an audit rule from the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity whose rule will be removed.
- rights ADPlayground.Acl.AclRights
- The rights associated with the rule.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to match.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
public static Void RestoreAdAclDefault(ActiveDirectorySecurity security, String defaultSecurityDescriptor, Boolean removeInheritedAccessRules) #VoidRestores the default ACL using the provided security descriptor string.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to reset.
- defaultSecurityDescriptor System.String
- The default security descriptor in SDDL form.
- removeInheritedAccessRules System.Boolean
- Whether inherited rules should be removed.
Examples
Restore default ACL on a security descriptor.
ACL.RestoreAdAclDefault(security, sddl, true);
public static Void RestoreAdAclDefault(DirectoryEntry entry, Boolean removeInheritedAccessRules) #VoidRestores the default ACL for the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- removeInheritedAccessRules System.Boolean
- Whether inherited rules should be removed.
public static AclChangeSet SetAdAcl(DirectoryEntry entry, IEnumerable<AclEntry> entries) #AclChangeSetReplaces ACL entries on a security descriptor with the specified set.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- entries System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry}
- The entries that should remain.
Returns
The change set describing modifications performed.
SetAdAcl(System.DirectoryServices.DirectoryEntry entry, System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry} entries) #Replaces ACL entries on the specified directory entry with the provided set.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- entries System.Collections.Generic.IEnumerable{ADPlayground.Acl.AclEntry}
- The entries that should remain.
Returns
The change set describing modifications performed.
public static Void SetAdAclAuditRule(DirectoryEntry entry, IdentityInfo identity, AclRights rights, AuditFlags flags, AclInheritance inheritance) #VoidSets an audit rule on the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- sid System.String
- The SID to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
SetAdAclAuditRule(System.DirectoryServices.ActiveDirectorySecurity security, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Sets an audit rule on the specified security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
SetAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, System.String sid, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Sets an audit rule on the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- sid System.String
- The SID to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
SetAdAclAuditRule(System.DirectoryServices.DirectoryEntry entry, ADPlayground.Identity.IdentityInfo identity, ADPlayground.Acl.AclRights rights, System.Security.AccessControl.AuditFlags flags, ADPlayground.Acl.AclInheritance inheritance) #Sets an audit rule on the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- identity ADPlayground.Identity.IdentityInfo
- The identity to audit.
- rights ADPlayground.Acl.AclRights
- The rights to audit.
- flags System.Security.AccessControl.AuditFlags
- The audit flags to apply.
- inheritance ADPlayground.Acl.AclInheritance
- The inheritance type of the rule.
public static Void SetAdAclInheritance(DirectoryEntry entry, Boolean enable, Boolean removeInheritedAccessRules = false) #VoidSets ACL inheritance on a security descriptor.
Parameters
- security System.DirectoryServices.ActiveDirectorySecurity
- The security descriptor to modify.
- enable System.Boolean
- Whether inheritance should be enabled.
- removeInheritedAccessRules System.Boolean = false
- Whether to remove inherited rules when disabling.
SetAdAclInheritance(System.DirectoryServices.DirectoryEntry entry, System.Boolean enable, System.Boolean removeInheritedAccessRules) #Sets ACL inheritance on the specified directory entry.
Parameters
- entry System.DirectoryServices.DirectoryEntry
- The directory entry to modify.
- enable System.Boolean
- Whether inheritance should be enabled.
- removeInheritedAccessRules System.Boolean
- Whether to remove inherited rules when disabling.