Skip to content

Back to the Category Index / Back to the Command Index

Reads an LDAP object’s DACL and adds, removes, or restores ACEs. Targets can be specified by name, SID, or DN.

ItemDetails
Implementationexamples/dacledit.py
CategoryActive Directory / LDAP / Account Management
Size779 lines
DistributionInstalled as a script through scripts=examples/*.py in setup.py

Check python examples/dacledit.py -h for the current option definitions.

ArgumentDescription
identitydomain.local/username[:password]
-ldaps / -use-ldapsUse LDAPS instead of LDAP.
-tsAdd timestamps to log output.
-debugEnable debug logging.
-hashesNTLM hashes in LMHASH:NTHASH format.
-no-passSkip the password prompt (useful with -k).
-kUse Kerberos authentication. Read credentials from the ccache (KRB5CCNAME) based on the target; fall back to command-line credentials if none are valid.
-aesKey128- or 256-bit AES key for Kerberos authentication.
-dc-ipIP address of the domain controller or KDC for Kerberos. Defaults to the domain (FQDN) in identity.
-dc-hostHostname of the domain controller or KDC for Kerberos. Uses -dc-ip if omitted.
-principalPrincipal sAMAccountName.
-principal-sidPrincipal security identifier.
-principal-dnPrincipal distinguished name.
-targetTarget sAMAccountName.
-target-sidTarget security identifier.
-target-dnTarget distinguished name.
-actionDACL operation. Choices: read, write, remove, backup, restore. Default: read.
-fileFile path; optional for -action backup and required for restore.
-ace-typeACE type to add or remove. Choices: allowed, denied. Default: allowed.
-rightsRights to add or remove from the target DACL. Choices: FullControl, ResetPassword, WriteMembers, DCSync, Custom. Default: FullControl.
-rights-guidGUID of the right to add or remove.
-maskAccess mask: readwrite, write, self, allext, or 0xXXXXX. Useful with -rights Custom or -rights-guid when the mask differs from read+write.
-inheritanceSet CONTAINER_INHERIT_ACE and OBJECT_INHERIT_ACE in the ACE flags. For a container or OU, child objects inherit the ACE except those with adminCount=1.

Related technology: LDAP and AD Security Descriptors covers ACE types, GUIDs, and SD controls. impacket.acl is not used.

After LDAP bind, the command resolves the target DN and principal SID, then retrieves the descriptor with a security descriptor control. read parses and displays ACEs; write / remove build or change ACEs from rights and inheritance, then perform LDAP modify. The original descriptor can be saved as backup JSON and restored with restore.

An LDAP object’s DACL is an ordered sequence of ACEs, not simply a set of permission names. The command retrieves the binary descriptor using a security descriptor control and breaks each ACE into its type, trustee SID, access mask, object GUID, and inheritance flags. read maps this structure to human-readable permissions.

write expands higher-level selections such as FullControl and DCSync into one or more ACEs and GUIDs/masks, then appends them to the existing DACL. remove deletes only ACEs matching the same conditions. For object-specific ACEs, the GUID and mask combination matters; an ACE must not be removed merely because its SID matches. Inheritance changes the scope across the container and its child objects.

backup / restore store the original binary descriptor in JSON, not the displayed result, so unknown ACEs and their order can be restored. Changes must preserve canonical ACE order, descriptor control flags, and untargeted owner/group/SACL data. If LDAP modify fails, do not expose a state where only the local object has been changed.

SymbolLocationEntry Point for Tracing Behavior
RIGHTS_GUID130Structure and constant definitions
ACE_FLAGS140Structure and constant definitions
OBJECT_ACE_FLAGS154Structure and constant definitions
ACCESS_MASK163Structure and constant definitions
SIMPLE_PERMISSIONS198Structure and constant definitions
ALLOWED_OBJECT_ACE_MASK_FLAGS211Structure and constant definitions
DACLedit220__init__(), read(), write(), remove(), backup(), restore(), search_target_principal_security_descriptor(), get_user_info(), resolveSID(), parseDACL(), parsePerms(), parseACE(), and others
parse_args()699Module function
main()741Module function
ModuleMain Names Used
impacketversion
impacket.exampleslogger, utils
impacket.ldapldaptypes
impacket.msada_guidsEXTENDED_RIGHTS, SCHEMA_OBJECTS
impacket.uuidbin_to_string, string_to_bin
impacket.examples.utilsinit_ldap_session, parse_identity
Import NameDistribution PackageUsage / Declaration Status
ldap3ldap3Imported directly; declared dependency
ldapdomaindumpldapdomaindumpImported directly; declared dependency

Output, Side Effects, and Required Privileges

Section titled “Output, Side Effects, and Required Privileges”
  • Some operations change the target’s state. Confirm the target name, SID, and path before making changes.
  • On failure, use protocol status to determine whether name resolution, connection, authentication, service state, or permissions stopped the operation.

This command depends on ldap3, ldapdomaindump, ldaptypes, and msada_guids. DACLedit handles resolution, parsing, and changes. Preserve ACE order, object-specific GUIDs, inheritance flags, and the binary backup representation.