Skip to content

Commit af082c9

Browse files
committed
more progress
1 parent 033fa92 commit af082c9

File tree

7 files changed

+246
-13
lines changed

7 files changed

+246
-13
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Santiago Squarzon
3+
Copyright (c) 2025 Santiago Squarzon
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
---
2+
external help file: ADEffectiveAccess.dll-Help.xml
3+
Module Name: ADEffectiveAccess
4+
online version:
5+
schema: 2.0.0
6+
---
7+
8+
# Get-ADEffectiveAccess
9+
10+
## SYNOPSIS
11+
12+
{{ Fill in the Synopsis }}
13+
14+
## SYNTAX
15+
16+
```powershell
17+
Get-ADEffectiveAccess [[-LdapFilter] <String>] [-Audit] [-Top <Int32>] [-IncludeDeletedObjects]
18+
[-SearchScope <SearchScope>] [-Credential <PSCredential>] [-Server <String>]
19+
[-ProgressAction <ActionPreference>] [<CommonParameters>]
20+
```
21+
22+
## DESCRIPTION
23+
24+
{{ Fill in the Description }}
25+
26+
## EXAMPLES
27+
28+
### Example 1
29+
30+
```powershell
31+
PS C:\> {{ Add example code here }}
32+
```
33+
34+
{{ Add example description here }}
35+
36+
## PARAMETERS
37+
38+
### -Audit
39+
40+
{{ Fill Audit Description }}
41+
42+
```yaml
43+
Type: SwitchParameter
44+
Parameter Sets: (All)
45+
Aliases:
46+
47+
Required: False
48+
Position: Named
49+
Default value: None
50+
Accept pipeline input: False
51+
Accept wildcard characters: False
52+
```
53+
54+
### -Credential
55+
56+
{{ Fill Credential Description }}
57+
58+
```yaml
59+
Type: PSCredential
60+
Parameter Sets: (All)
61+
Aliases:
62+
63+
Required: False
64+
Position: Named
65+
Default value: None
66+
Accept pipeline input: False
67+
Accept wildcard characters: False
68+
```
69+
70+
### -IncludeDeletedObjects
71+
72+
{{ Fill IncludeDeletedObjects Description }}
73+
74+
```yaml
75+
Type: SwitchParameter
76+
Parameter Sets: (All)
77+
Aliases:
78+
79+
Required: False
80+
Position: Named
81+
Default value: None
82+
Accept pipeline input: False
83+
Accept wildcard characters: False
84+
```
85+
86+
### -LdapFilter
87+
88+
{{ Fill LdapFilter Description }}
89+
90+
```yaml
91+
Type: String
92+
Parameter Sets: (All)
93+
Aliases:
94+
95+
Required: False
96+
Position: 0
97+
Default value: None
98+
Accept pipeline input: False
99+
Accept wildcard characters: False
100+
```
101+
102+
### -SearchScope
103+
104+
{{ Fill SearchScope Description }}
105+
106+
```yaml
107+
Type: SearchScope
108+
Parameter Sets: (All)
109+
Aliases:
110+
Accepted values: Base, OneLevel, Subtree
111+
112+
Required: False
113+
Position: Named
114+
Default value: None
115+
Accept pipeline input: False
116+
Accept wildcard characters: False
117+
```
118+
119+
### -Server
120+
121+
{{ Fill Server Description }}
122+
123+
```yaml
124+
Type: String
125+
Parameter Sets: (All)
126+
Aliases:
127+
128+
Required: False
129+
Position: Named
130+
Default value: None
131+
Accept pipeline input: False
132+
Accept wildcard characters: False
133+
```
134+
135+
### -Top
136+
137+
{{ Fill Top Description }}
138+
139+
```yaml
140+
Type: Int32
141+
Parameter Sets: (All)
142+
Aliases:
143+
144+
Required: False
145+
Position: Named
146+
Default value: None
147+
Accept pipeline input: False
148+
Accept wildcard characters: False
149+
```
150+
151+
### -ProgressAction
152+
153+
{{ Fill ProgressAction Description }}
154+
155+
```yaml
156+
Type: ActionPreference
157+
Parameter Sets: (All)
158+
Aliases: proga
159+
160+
Required: False
161+
Position: Named
162+
Default value: None
163+
Accept pipeline input: False
164+
Accept wildcard characters: False
165+
```
166+
167+
### CommonParameters
168+
169+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
170+
171+
## INPUTS
172+
173+
### None
174+
175+
## OUTPUTS
176+
177+
### System.Object
178+
179+
## NOTES
180+
181+
## RELATED LINKS

module/ADEffectiveAccess.psd1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Description = ''
3434

3535
# Minimum version of the PowerShell engine required by this module
36-
# PowerShellVersion = ''
36+
PowerShellVersion = '5.1'
3737

3838
# Name of the PowerShell host required by this module
3939
# PowerShellHostName = ''
@@ -72,13 +72,13 @@
7272
FunctionsToExport = @()
7373

7474
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
75-
CmdletsToExport = @("Get-ADEffectiveAccess")
75+
CmdletsToExport = @('Get-ADEffectiveAccess')
7676

7777
# Variables to export from this module
7878
VariablesToExport = @()
7979

8080
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
81-
AliasesToExport = @()
81+
AliasesToExport = @('gea', 'gacl')
8282

8383
# DSC resources to export from this module
8484
# DscResourcesToExport = @()
@@ -98,10 +98,10 @@
9898
# Tags = @()
9999

100100
# A URL to the license for this module.
101-
# LicenseUri = ''
101+
LicenseUri = 'https://github.com/santisq/ADEffectiveAccess/blob/main/LICENSE'
102102

103103
# A URL to the main website for this project.
104-
# ProjectUri = ''
104+
ProjectUri = 'https://github.com/santisq/ADEffectiveAccess'
105105

106106
# A URL to an icon representing this module.
107107
# IconUri = ''
@@ -123,7 +123,7 @@
123123
} # End of PrivateData hashtable
124124

125125
# HelpInfo URI of this module
126-
# HelpInfoURI = ''
126+
HelpInfoURI = ''
127127

128128
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
129129
# DefaultCommandPrefix = ''

src/ADEffectiveAccess/AclBuilder.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,27 @@ internal AclBuilder(string path, byte[] descriptor) : base()
2424
_group = GetGroup(_targetType);
2525
}
2626

27-
internal IEnumerable<EffectiveAccessRule> EnumerateAccessRules()
27+
internal IEnumerable<EffectiveAccessRule> EnumerateAccessRules(SchemaMap map)
2828
{
2929
foreach (ActiveDirectoryAccessRule rule in GetAccessRules(true, true, _targetType))
3030
{
31-
yield return new EffectiveAccessRule(rule, _owner, _group, _path);
31+
yield return new EffectiveAccessRule(rule, _owner, _group, _path)
32+
{
33+
ObjectTypeToString = map.Translate(rule.ObjectType, "All Objects (Full Control)"),
34+
InheritedObjectTypeToString = map.Translate(rule.InheritedObjectType, "Any Inherited Object")
35+
};
3236
}
3337
}
3438

35-
internal IEnumerable<EffectiveAuditRule> EnumerateAuditRules()
39+
internal IEnumerable<EffectiveAuditRule> EnumerateAuditRules(SchemaMap map)
3640
{
3741
foreach (ActiveDirectoryAuditRule rule in GetAuditRules(true, true, _targetType))
3842
{
39-
yield return new EffectiveAuditRule(rule, _owner, _group, _path);
43+
yield return new EffectiveAuditRule(rule, _owner, _group, _path)
44+
{
45+
ObjectTypeToString = map.Translate(rule.ObjectType, "All Objects (Full Control)"),
46+
InheritedObjectTypeToString = map.Translate(rule.InheritedObjectType, "Any Inherited Object")
47+
};
4048
}
4149
}
4250
}

src/ADEffectiveAccess/EffectiveRule.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ public abstract class EffectiveRule<T>(
2424
public bool IsInherited { get => Rule.IsInherited; }
2525

2626
public PropagationFlags PropagationFlags { get => Rule.PropagationFlags; }
27+
28+
public string? ObjectTypeToString { get; internal set; }
29+
30+
public string? InheritedObjectTypeToString { get; internal set; }
2731
}

src/ADEffectiveAccess/GetADEffectiveAccessComand.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
namespace ADEffectiveAccess;
66

77
[Cmdlet(VerbsCommon.Get, "ADEffectiveAccess")]
8+
[Alias("gea", "gacl")]
89
public sealed class GetADEffectiveAccessComand : PSCmdlet
910
{
1011
private const string SecurityDescriptor = "nTSecurityDescriptor";
1112

13+
private SchemaMap? _map;
14+
1215
[Parameter(Position = 0)]
1316
public string? LdapFilter { get; set; }
1417

@@ -25,6 +28,29 @@ public sealed class GetADEffectiveAccessComand : PSCmdlet
2528
[Parameter]
2629
public SearchScope SearchScope { get; set; } = SearchScope.Subtree;
2730

31+
[Parameter]
32+
[Credential]
33+
public PSCredential? Credential { get; set; }
34+
35+
[Parameter]
36+
public string? Server { get; set; }
37+
38+
protected override void BeginProcessing()
39+
{
40+
try
41+
{
42+
_map = new SchemaMap(Server);
43+
}
44+
catch (Exception exception)
45+
{
46+
ErrorRecord error = new(
47+
exception, "SchemaMapCreationFailure",
48+
ErrorCategory.ConnectionError, null);
49+
50+
ThrowTerminatingError(error);
51+
}
52+
}
53+
2854
protected override void EndProcessing()
2955
{
3056
using DirectorySearcher searcher = new(LdapFilter, [SecurityDescriptor])
@@ -55,11 +81,15 @@ protected override void EndProcessing()
5581
}
5682

5783
AclBuilder builder = new(obj.Path, descriptor);
58-
WriteObject(builder.EnumerateAccessRules(), enumerateCollection: true);
84+
WriteObject(
85+
builder.EnumerateAccessRules(_map!),
86+
enumerateCollection: true);
5987

6088
if (Audit)
6189
{
62-
WriteObject(builder.EnumerateAuditRules(), enumerateCollection: true);
90+
WriteObject(
91+
builder.EnumerateAuditRules(_map!),
92+
enumerateCollection: true);
6393
}
6494
}
6595
}

src/ADEffectiveAccess/SchemaMap.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ internal SchemaMap(string? server = null)
1616
if (ctx is not null) PopulateMap(ctx, _schemaMap);
1717
}
1818

19+
internal string Translate(Guid guid, string defaultValue)
20+
{
21+
if (guid == Guid.Empty || _schemaMap.TryGetValue(guid, out defaultValue))
22+
{
23+
return defaultValue;
24+
}
25+
26+
return guid.ToString();
27+
}
28+
1929
private static void PopulateMap(
2030
string schemaNamingContext,
2131
Dictionary<Guid, string> map)

0 commit comments

Comments
 (0)