Skip to content

Commit acc080c

Browse files
Update accessrules.md
1 parent 2188b60 commit acc080c

File tree

1 file changed

+175
-0
lines changed

1 file changed

+175
-0
lines changed

documentation/components/domain/accessrules.md

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,181 @@ Then update the identity as need to use [Name Mapping / Name Resolution](../../a
8181

8282
You can also use `Convert-DMSchemaGuid` to translate the GUIDs into humanly readable names.
8383

84+
> Transfer from Test Result
85+
86+
If you already have some settings deployed and are testing access rules using `Test-AdmfDomain`, you can convert test results into configuration entries.
87+
88+
This command will convert test results into suitable datasets:
89+
90+
```powershell
91+
function ConvertTo-AccessRuleConfiguration {
92+
<#
93+
.SYNOPSIS
94+
Tool to convert Access Rule test results into configuration sets.
95+
96+
.DESCRIPTION
97+
Tool to convert Access Rule test results into configuration sets.
98+
99+
.PARAMETER Path
100+
Replace the path the results should apply to.
101+
By default, paths should be auto-detected.
102+
103+
.PARAMETER ObjectCategory
104+
Name of the object category that the result should be applied to.
105+
By default, rules are applied to paths of the origin.
106+
107+
.PARAMETER InputObject
108+
The test result to convert.
109+
110+
.PARAMETER Clip
111+
Converts results to json and pastes them to clipboard.
112+
113+
.EXAMPLE
114+
PS C:\> $res | ConvertTo-AccessRuleConfiguration
115+
116+
Converts the input test result to configuration rules
117+
118+
.EXAMPLE
119+
PS C:\> $res | carc -ObjectCategory trustuser -Clip
120+
121+
Converts the input test result to configuration rules that apply to the object category "trustuser".
122+
Then it converts the results to json and pastes it to the clipboard
123+
#>
124+
[Alias('carc')]
125+
[CmdletBinding()]
126+
param (
127+
[string]
128+
$Path,
129+
130+
[string]
131+
$ObjectCategory,
132+
133+
[Parameter(ValueFromPipeline = $true)]
134+
$InputObject,
135+
136+
[switch]
137+
$Clip
138+
)
139+
140+
begin {
141+
function Convert-Identity {
142+
[CmdletBinding()]
143+
param (
144+
[Parameter(ValueFromPipeline = $true)]
145+
[string]
146+
$Name
147+
)
148+
149+
begin {
150+
$builtIn = @{
151+
'BUILTIN\Administrators' = 'S-1-5-32-544'
152+
'BUILTIN\Users' = 'S-1-5-32-545'
153+
'BUILTIN\Guests' = 'S-1-5-32-546'
154+
'BUILTIN\Account Operators' = 'S-1-5-32-548'
155+
'BUILTIN\Server Operators' = 'S-1-5-32-549'
156+
'BUILTIN\Print Operators' = 'S-1-5-32-550'
157+
'BUILTIN\Backup Operators' = 'S-1-5-32-551'
158+
'BUILTIN\Replicator' = 'S-1-5-32-552'
159+
'BUILTIN\Pre-Windows 2000 Compatible Access' = 'S-1-5-32-554'
160+
'BUILTIN\Remote Desktop Users' = 'S-1-5-32-555'
161+
'BUILTIN\Network Configuration Operators' = 'S-1-5-32-556'
162+
'BUILTIN\Incoming Forest Trust Builders' = 'S-1-5-32-557'
163+
'BUILTIN\Performance Monitor Users' = 'S-1-5-32-558'
164+
'BUILTIN\Performance Log Users' = 'S-1-5-32-559'
165+
'BUILTIN\Windows Authorization Access Group' = 'S-1-5-32-560'
166+
'BUILTIN\Terminal Server License Servers' = 'S-1-5-32-561'
167+
'BUILTIN\Distributed COM Users' = 'S-1-5-32-562'
168+
'BUILTIN\IIS_IUSRS' = 'S-1-5-32-568'
169+
'BUILTIN\Cryptographic Operators' = 'S-1-5-32-569'
170+
'BUILTIN\Event Log Readers' = 'S-1-5-32-573'
171+
'BUILTIN\Certificate Service DCOM Access' = 'S-1-5-32-574'
172+
'BUILTIN\RDS Remote Access Servers' = 'S-1-5-32-575'
173+
'BUILTIN\RDS Endpoint Servers' = 'S-1-5-32-576'
174+
'BUILTIN\RDS Management Servers' = 'S-1-5-32-577'
175+
'BUILTIN\Hyper-V Administrators' = 'S-1-5-32-578'
176+
'BUILTIN\Access Control Assistance Operators' = 'S-1-5-32-579'
177+
'BUILTIN\Remote Management Users' = 'S-1-5-32-580'
178+
'BUILTIN\Storage Replica Administrators' = 'S-1-5-32-582'
179+
}
180+
}
181+
182+
process {
183+
if ($builtIn[$Name]) { return $builtIn[$Name] }
184+
185+
$sid = $Name -as [System.Security.Principal.SecurityIdentifier]
186+
if (-not $sid) {
187+
try { $sid = ([System.Security.Principal.NTAccount]$Name).Translate([System.Security.Principal.SecurityIdentifier]) }
188+
catch { return $Name }
189+
}
190+
191+
# Case: Builtin SID
192+
if (-not $sid.AccountDomainSid) { return $sid -as [string] }
193+
194+
$rid = ($sid.Value -split '-')[-1]
195+
if (1000 -gt $rid) {
196+
return "%DomainSID%-$rid"
197+
}
198+
$Name
199+
}
200+
}
201+
202+
$list = [System.Collections.ArrayList]@()
203+
}
204+
process {
205+
$data = $InputObject
206+
if ($InputObject.Changed) { $data = $InputObject.Changed }
207+
foreach ($datum in $data) {
208+
$source = $datum.ADObject
209+
if ($datum.Configuration) { $source = $datum.Configuration }
210+
$hash = @{
211+
Identity = $source.IdentityReference | Convert-Identity
212+
ActiveDirectoryRights = $source.ActiveDirectoryRights -as [string]
213+
InheritanceType = $source.InheritanceType -as [string]
214+
AccessControlType = $source.AccessControlType -as [string]
215+
ObjectType = $source.ObjectType -as [string]
216+
InheritedObjectType = $source.InheritedObjectType -as [string]
217+
}
218+
if ($Path) { $hash.Path = $Path }
219+
elseif ($ObjectCategory) { $hash.ObjectCategory = $ObjectCategory }
220+
else {
221+
if ($InputObject.Identity) {
222+
$hash.Path = $InputObject.Identity | Set-String -OldValue 'DC=.+' -NewValue '%DomainDN%'
223+
}
224+
elseif ($datum.DistinguishedName) {
225+
$hash.Path = $datum.DistinguishedName | Set-String -OldValue 'DC=.+' -NewValue '%DomainDN%'
226+
}
227+
else {
228+
$hash.Path = "INSERT_HERE"
229+
}
230+
}
231+
232+
switch ($datum.Type) {
233+
'Restore' { $hash.Present = $false }
234+
}
235+
236+
if ($Clip) { $null = $list.Add([PSCustomObject]$hash)}
237+
else { [PSCustomObject]$hash }
238+
}
239+
}
240+
end {
241+
if ($Clip) {
242+
$list | ConvertTo-Json | Set-Clipboard
243+
}
244+
}
245+
}
246+
```
247+
248+
With that you can then convert results like this:
249+
250+
```powershell
251+
# Plain Convert
252+
$res = Test-AdmfDomain -Server contoso.com
253+
$res | ConvertTo-AccessRuleConfiguration
254+
255+
# Short form straight to clipboard
256+
$res | carc -ObjectCategory trustuser -Clip
257+
```
258+
84259
## Properties
85260

86261
### Path

0 commit comments

Comments
 (0)