Skip to content

Commit 8b72387

Browse files
SteveL-MSFTSteve Lee (POWERSHELL HE/HIM) (from Dev Box)Copilot
authored
Add ACL support to Registry resources (#1752)
* Add registry ACL support Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Address registry ACL review feedback Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Use minimal access for registry ACL reads Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Bump Registry resource version to 1.3.0 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Steve Lee (POWERSHELL HE/HIM) (from Dev Box) <slee@ntdev.microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 5682a6f commit 8b72387

16 files changed

Lines changed: 630 additions & 6 deletions

File tree

‎Cargo.lock‎

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ urlencoding = { version = "2.1" }
290290
which = { version = "8.0.6" }
291291
# dsc-lib
292292
ipnetwork = { version = "0.21" }
293-
# WindowsUpdate, windows_service, dsc-lib (ACL checks)
293+
# WindowsUpdate, windows_service, dsc-lib (ACL checks), dsc-lib-registry
294294
windows = { version = "0.62", features = [
295295
"Win32_Foundation",
296296
"Win32_NetworkManagement_WindowsFirewall",
@@ -299,6 +299,7 @@ windows = { version = "0.62", features = [
299299
"Win32_System_Com",
300300
"Win32_System_Memory",
301301
"Win32_System_Ole",
302+
"Win32_System_Registry",
302303
"Win32_System_Services",
303304
"Win32_System_Variant",
304305
"Win32_System_UpdateAgent",

‎docs/reference/resources/Microsoft/Windows/Registry/index.md‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
description: Microsoft.Windows/Registry resource reference documentation
3-
ms.date: 03/25/2025
3+
ms.date: 10/13/2026
44
ms.topic: reference
55
title: Microsoft.Windows/Registry
66
---
@@ -35,6 +35,7 @@ resources:
3535
keyPath: string
3636
# Instance properties
3737
_exist:
38+
acl:
3839
valueData:
3940
valueName:
4041
```
@@ -46,6 +47,7 @@ values. The resource can:
4647

4748
- Add and remove registry keys.
4849
- Add, update, and remove registry values.
50+
- Retrieve and configure registry key access control lists (ACLs).
4951

5052
> [!NOTE]
5153
> This resource is installed with DSC itself on Windows systems.
@@ -106,6 +108,7 @@ The following list describes the properties for the resource.
106108
They define the desired state for an instance of the resource.
107109

108110
- [_exist](#_exist) - Defines whether the registry key or value should exist.
111+
- [acl](#acl) - Defines the registry key ACL in Security Descriptor Definition Language (SDDL).
109112
- [valueData](#valuedata) - The data for a registry value.
110113
- [valueName](#valuename) - The name of the registry value.
111114

@@ -162,6 +165,28 @@ value for `_exist` is `true`, the resource adds or creates the instance if it do
162165
the value for `_exist` is `false`, the resource removes or deletes the instance if it does exist.
163166
The default value for this property when not specified for an instance is `true`.
164167

168+
### acl
169+
170+
<details><summary>Expand for <code>acl</code> property metadata</summary>
171+
172+
```yaml
173+
Type : string
174+
IsRequired : false
175+
IsKey : false
176+
IsReadOnly : false
177+
IsWriteOnly : false
178+
```
179+
180+
</details>
181+
182+
Defines the registry key ACL in Security Descriptor Definition Language (SDDL). For **Get**
183+
operations, include the owner (`O:`), group (`G:`), or discretionary access control list (`D:`)
184+
section in the input to retrieve those sections. For **Set** operations, the resource applies only
185+
the sections specified in the SDDL string. System access control lists (`S:`) aren't supported.
186+
187+
This property applies to the key identified by `keyPath`, including when the instance also specifies
188+
a registry value. ACL operations aren't supported when using an offline registry hive.
189+
165190
### valueData
166191

167192
<details><summary>Expand for <code>valueData</code> property metadata</summary>
@@ -378,6 +403,9 @@ non validating keywords are omitted.
378403
}
379404
}
380405
},
406+
"acl": {
407+
"type": "string"
408+
},
381409
"keyPath": {
382410
"type": "string",
383411
"pattern": "^(HKCR|HKEY_CLASSES_ROOT|HKCU|HKEY_CURRENT_USER|HKLM|HKEY_LOCAL_MACHINE|HKU|HKEY_USERS|HKCC|HKEY_CURRENT_CONFIG)\\\\"

‎lib/dsc-lib-registry/Cargo.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dsc-lib-registry"
3-
version = "1.2.0"
3+
version = "1.3.0"
44
edition = "2024"
55

66
[package.metadata.i18n]
@@ -22,6 +22,7 @@ thiserror = { workspace = true }
2222
tracing = { workspace = true }
2323
tracing-subscriber = { workspace = true }
2424
utfx = { workspace = true }
25+
windows = { workspace = true }
2526

2627
[build-dependencies]
2728
cc = { workspace = true }

‎lib/dsc-lib-registry/locales/en-us.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,25 @@ _version = 1
44
# No localizable strings
55

66
[error]
7+
acl = "Registry ACL"
8+
invalidAcl = "The SDDL must define an owner, group, or DACL"
79
invalidHive = "Invalid hive"
810
json = "JSON"
911
offlineRegistry = "Offline registry"
12+
offlineAcl = "ACL operations are not supported for offline registries"
1013
offlineValueEnumeration = "Value enumeration is not supported for offline registries"
1114
registry = "Registry"
1215
registryKey = "Registry key"
1316
registryKeyNotFound = "Registry key not found"
1417
registryValue = "Registry value"
18+
saclUnsupported = "System ACLs (SACLs) are not supported"
1519
utf16Conversion = "UTF-16 conversion failed due to interior NULL values for"
1620
unsupportedValueDataType = "Unsupported registry value data type"
21+
win32 = "%{operation} failed with error code %{code}"
1722

1823
[registry_helper]
1924
whatIfCreateKey = "Key '%{subkey}' not found, would create it"
25+
whatIfSetAcl = "Would set ACL on key '%{key_path}'"
2026
whatIfDeleteValue = "Would delete value '%{value_name}'"
2127
whatIfDeleteSubkey = "Would delete subkey '%{subkey_name}'"
2228
whatIfDeleteNonexistingKey = "Key '%{subkey}' not found, would do nothing"

0 commit comments

Comments
 (0)