Set a Windows DACL by first defining which trustees need which operations, then build the ACL with the Windows security APIs, use the least access necessary, and verify the effective result. The critical safety rules are simple: an absent or null DACL is permissive, an empty DACL denies everyone, allow ACEs usually suffice, and any required deny ACE must appear before the allow ACE it is intended to override.
What a DACL actually controls
A discretionary access control list (DACL) is part of a Windows security descriptor. It contains access control entries (ACEs); each ACE names a trustee, such as a user or group, and specifies allowed or denied rights. Windows evaluates those entries when an identity requests an operation on the securable object.
There is no universal “correct” DACL. A folder used for shared documents, a private application data file, and a service endpoint have different trustees and required operations. Microsoft advises using the ACL functions to create and manipulate ACLs rather than editing ACL contents directly: Access Control Lists.
Distinguish absent, empty, and null DACLs
These states have sharply different results. Treating them as interchangeable is a common way to expose data or lock out every caller.
#1 Best Overall
| DACL state | Meaning in the security descriptor | Access result | Typical use |
|---|---|---|---|
| Absent (no DACL present) | The descriptor indicates that it has no DACL. | Everyone receives full access in the documented Windows behavior. | Almost never an intentional protection policy; do not use as a shortcut. |
| Present but empty | A DACL exists but contains zero ACEs. | No access is granted through the DACL, so requests are denied. | A deliberate deny-all state, usually only for controlled isolation or testing. |
| Present and null | The descriptor says a DACL is present, but the DACL pointer is NULL. | Everyone receives full access. | Dangerous unless unrestricted access is explicitly intended. |
| Present with ACEs | The DACL contains explicit allow and/or deny entries. | Windows evaluates the ACEs and the requested rights. | The normal way to express a least-privilege policy. |
The distinction between an empty and null DACL is especially important when calling SetSecurityDescriptorDacl. A present flag with a NULL ACL pointer creates a null DACL; a present flag with an allocated ACL containing no ACEs creates an empty DACL. Passing a NULL DACL pointer to SetSecurityInfo while requesting DACL_SECURITY_INFORMATION likewise gives everyone full access, as documented for SetSecurityInfo. The behavior of SetSecurityDescriptorDacl is described in its Microsoft Learn reference.
Design the policy before writing the ACL
- Identify the securable object. Determine whether it is a file, directory, registry key, service, process, or another object type. Rights and inheritance semantics depend on the object type.
- List trustees. Name the users, groups, service accounts, or other security principals that must access it. Avoid granting broad principals such as Everyone unless that exposure is intentional.
- Map operations to rights. Decide whether each trustee needs read, write, execute, delete, change-permissions, or another object-specific right. Grant only the operations required for the job.
- Decide the inheritance boundary. Specify whether entries should apply only to the object, to child containers, to child objects, or to both. Inherited permissions are part of the policy, not an afterthought.
- Choose an API based on object identification. Use handle-based functions when you already hold a handle; use name-based functions when the target is identified by a path or other name.
Document the intended result before deployment. This gives you a reference for checking the resulting descriptor and for testing access with the identities that will actually operate the system.
Rank #2
Choose the Windows API that matches the target
| Situation | Functions | What you supply | Important requirement |
|---|---|---|---|
| You have an object handle | GetSecurityInfo and SetSecurityInfo |
The handle, object type, security-information flags, and the new DACL pointer | Include DACL_SECURITY_INFORMATION when changing the DACL. The DACL pointer is ignored without that flag. |
| You identify the object by name | GetNamedSecurityInfo and SetNamedSecurityInfo |
The object name, object type, security-information flags, and the new DACL pointer | The caller must have WRITE_DAC access or own the object. |
Microsoft groups these choices in Security Descriptor Operations. For named objects, see the SetNamedSecurityInfoA reference; use the appropriate Unicode or encoding-specific variant in new code.
When using SetSecurityInfo, pass the object handle and type, select DACL_SECURITY_INFORMATION, and pass a pointer to the ACL you constructed. If that flag is selected and the pointer is NULL, the resulting null DACL grants full access. Check the function’s return value and preserve the error code before performing other calls.
Rank #3
Build allow ACEs first and keep ordering intentional
Windows processes ACEs in order. An access-allowed ACE grants rights to its trustee; an access-denied ACE blocks rights. Microsoft notes that allow ACEs are sufficient in most cases because rights not granted by the DACL are implicitly denied: DACLs and ACEs.
Prefer least-required allow entries
Start with only the allow ACEs needed by the identified trustees. This is easier to audit than a policy containing numerous explicit denies, and it avoids denying a group member who should receive access through another path.
Rank #4
Use an explicit deny only for a specific override
A deny can be appropriate when a particular user must be blocked even though that user belongs to a group that receives an allow entry. Put the user-specific deny ACE before the group allow ACE. If the allow is encountered first, the requested rights may already be granted and the later deny will not produce the intended result.
Do not assume the set functions will repair an unsafe order: the documented implementations do not reorder allow and deny ACEs. Construct the ACL in the order required by the policy, then inspect the resulting descriptor.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Best Value
Account for inheritance and child objects
Directory and container ACLs can include inheritable ACEs. When you set a DACL, those entries may propagate to existing child objects and containers. The resulting permissions can therefore affect more than the object named in the API call.
Decide the scope explicitly
- Use non-inheritable entries when the rule is for the current object only.
- Use container- and/or object-inherit flags when descendants should receive the rule.
- Define whether child objects may inherit, replace, or combine the parent rule according to the object type and security-descriptor behavior.
Expect propagation limitations
Propagation can be affected when a child cannot be opened or updated. The SetSecurityInfo documentation also warns against opening the object with MAXIMUM_ALLOWED when inheritance propagation is required, because the resulting access may not include the rights needed to update descendants. Plan for partial propagation, check errors, and inspect representative children after the change.
Verify the resulting permissions safely
- Read back the security descriptor and DACL after the set operation; do not assume a successful API call means the policy matches your design.
- Check that the DACL is present, that it is not unintentionally null, and that the ACE trustees, rights, flags, and order are correct.
- Inspect inheritance flags on the target and on representative child objects when the target is a container.
- Test the intended operations using controlled accounts that represent each trustee, including a user who belongs to multiple groups.
- Test failure cases: an identity that should be denied, an operation outside the grant, and access to a child that should not inherit the rule.
- Deploy only after the descriptor and observed access agree with the documented policy, and retain a rollback copy of the previous security descriptor where your change process permits it.
Perform these checks in a controlled environment first. A permission test should cover the actual operation (for example, opening, modifying, deleting, or changing permissions), not just whether a directory is visible.
Common mistakes and their corrections
| Mistake | Why it is unsafe | Correction |
|---|---|---|
| Passing NULL as the DACL pointer while setting DACL information | Creates a null DACL and grants full access. | Pass a real ACL containing the intended ACEs, or deliberately construct an empty ACL only when deny-all is the goal. |
| Confusing an empty ACL with a null ACL | One denies access; the other grants full access. | Set the DACL-present state and pointer consistently, then read back the descriptor. |
| Adding deny ACEs for every non-authorized identity | Creates conflicts and makes group-based access difficult to reason about. | Use least-privilege allow ACEs; add a narrowly scoped deny only when an override is required. |
| Putting a deny after the allow it should override | ACE evaluation order can let the allow grant the request first. | Place the specific deny before the broader allow. |
| Ignoring inheritance | Permissions may spread to existing descendants or fail to propagate completely. | Choose inheritance flags deliberately and verify child objects after the change. |
| Using a name API with insufficient authority | SetNamedSecurityInfo requires WRITE_DAC or ownership. |
Run under an authorized identity and request only the access needed to perform the change. |
A safe decision sequence
For most implementations, the following sequence avoids the highest-impact errors:
Free tools Windows power users keep installed
One-click scans. No signup required.
- Write the trustee-and-operation matrix for the object.
- Select handle-based or name-based security-descriptor functions.
- Construct a non-null ACL with only the required allow ACEs.
- Add a specific deny only when a group grant must be overridden, placing that deny first.
- Mark inheritance deliberately for each ACE.
- Apply the ACL with
DACL_SECURITY_INFORMATIONand check the return status. - Read back and test the descriptor, including descendants when inheritance is involved.
Windows API support details and minimum platform entries vary by function; consult the current Microsoft Learn page for the target Windows and SDK versions rather than treating legacy support entries as a deployment recommendation.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

