Skip to content

Commit b6f4f74

Browse files
committed
i think this is done
1 parent 09dde32 commit b6f4f74

File tree

5 files changed

+139
-29
lines changed

5 files changed

+139
-29
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CHANGELOG
2+
3+
## [0.0.1] - 2025-10-19
4+
5+
- Rewritten in C# for improved performance and uploaded to the PowerShell Gallery.
6+
- Added enhanced functionality compared to the [original PowerShell version](https://gist.github.com/santisq/a84af707780b1168f1fa390632096a5a), including LDAP search (`-LdapFilter`), audit rules (`-Audit`), deleted object support (`-IncludeDeletedObjects`), and pipeline input from AD cmdlets. See the [Parameters section](./docs/en-US/Get-ADEffectiveAccess.md#parameters) for details.
7+
- Implemented per-session, per-domain caching for GUID translation (`ObjectType` and `InheritedObjectType`), improving efficiency and reducing LDAP queries.
8+
- Enhanced error handling for invalid search bases and identity resolution, ensuring robust validation.

README.md

Lines changed: 102 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,130 @@
1-
# Get-EffectiveAccess
1+
<h1 align="center">ADEffectiveAccess</h1>
22

3-
## Description
3+
<div align="center">
4+
<sub>AD ACLs with readable rights, flexible LDAP and no AD module needed</sub>
5+
<br /><br />
6+
7+
[![build](https://github.com/santisq/ADEffectiveAccess/actions/workflows/ci.yml/badge.svg)](https://github.com/santisq/ADEffectiveAccess/actions/workflows/ci.yml)
8+
[![PowerShell Gallery](https://img.shields.io/powershellgallery/v/ADEffectiveAccess?label=gallery)](https://www.powershellgallery.com/packages/ADEffectiveAccess)
9+
[![LICENSE](https://img.shields.io/github/license/santisq/ADEffectiveAccess)](https://github.com/santisq/ADEffectiveAccess/blob/main/LICENSE)
10+
11+
</div>
412

513
> [!NOTE]
6-
> This function is being rewritten to C#, you can find the original version in [this Gist](https://gist.github.com/santisq/a84af707780b1168f1fa390632096a5a)
14+
> This module has been rewritten in C# for improved performance and maintainability. The original PowerShell version is available in [this Gist](https://gist.github.com/santisq/a84af707780b1168f1fa390632096a5a).
15+
16+
ADEffectiveAccess is a PowerShell module that provides the `Get-ADEffectiveAccess` cmdlet, an enhanced alternative to `Get-Acl` for Active Directory. This cmdlet retrieves access control lists (ACLs) for AD objects, returning effective access and audit rules. It translates `ObjectType` and `InheritedObjectType` GUIDs into human-readable names using a per-session, per-domain map for improved performance and readability.
17+
18+
Unlike `Get-Acl`, there is no dependency on the Active Directory module and includes built-in LDAP search functionality to locate objects.
19+
20+
## Documentation
21+
22+
Check out [__the documentation__](./docs/en-US/Get-ADEffectiveAccess.md) for cmdlet usage and more examples.
23+
24+
## Installation
25+
26+
### Gallery
27+
28+
The module is available through the [PowerShell Gallery](https://www.powershellgallery.com/packages/ADEffectiveAccess):
29+
30+
```powershell
31+
Install-Module ADEffectiveAccess -Scope CurrentUser
32+
```
33+
34+
### Source
735

8-
PowerShell function that tries to give a friendly translation of [`Get-Acl`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-acl?view=powershell-7.2) into human readable data. The function is designed exclusively for Active Directory, and requires the [__ActiveDirectory Module__](https://docs.microsoft.com/en-us/powershell/module/activedirectory/?view=windowsserver2022-ps).
36+
```powershell
37+
git clone 'https://github.com/santisq/ADEffectiveAccess.git'
38+
Set-Location ./ADEffectiveAccess
39+
./build.ps1
40+
```
41+
42+
## Requirements
43+
44+
This module requires __Windows OS__ and is compatible with __Windows PowerShell v5.1__ and [__PowerShell 7+__](https://github.com/PowerShell/PowerShell). No Active Directory module is required. Appropriate permissions are needed to read security descriptors.
45+
46+
## Usage
47+
48+
Below are examples demonstrating how to use `Get-ADEffectiveAccess` to retrieve Active Directory ACLs:
949

10-
## Examples
50+
### Get ACL for a specific user by sAMAccountName
1151

12-
- Get the _Effective Access_ of the Organizational Unit named `ExampleOU`:
52+
Retrieves effective access rules for the user `john.galt` in the current domain.
1353

1454
```powershell
15-
Get-ADOrganizationalUnit -Filter "Name -eq 'ExampleOU'" |
16-
Get-EffectiveAccess | Out-GridView
55+
PS /> $acl = Get-ADEffectiveAccess john.galt
56+
PS /> $acl
57+
58+
Path: LDAP://CN=John Galt,CN=Users,DC=mylab,DC=local
59+
60+
IdentityReference ObjectType InheritedObjectType ActiveDirectoryRights
61+
----------------- ---------- ------------------- ---------------------
62+
NT AUTHORITY\SELF All Objects (Full Control) Any Inherited Object GenericRead
63+
NT AUTHORITY\Authenticated Users All Objects (Full Control) Any Inherited Object ReadControl
64+
NT AUTHORITY\SYSTEM All Objects (Full Control) Any Inherited Object GenericAll
65+
BUILTIN\Account Operators All Objects (Full Control) Any Inherited Object GenericAll
66+
mylab\Domain Admins All Objects (Full Control) Any Inherited Object GenericAll
67+
Everyone User-Change-Password Any Inherited Object ExtendedRight
68+
NT AUTHORITY\SELF Email-Information Any Inherited Object ReadProperty, WriteProperty
69+
....
70+
71+
PS /> $acl[30] | Format-List
72+
73+
ActiveDirectoryRights : ReadProperty
74+
InheritanceType : Descendents
75+
ObjectType : 59ba2f42-79a2-11d0-9020-00c04fc2d3cf
76+
InheritedObjectType : 4828cc14-1437-45bc-9b07-ad6f015e5f28
77+
ObjectFlags : ObjectAceTypePresent, InheritedObjectAceTypePresent
78+
AccessControlType : Allow
79+
Type : Access
80+
Owner : mylab\Domain Admins
81+
Group : mylab\Domain Admins
82+
Path : LDAP://CN=John Galt,CN=Users,DC=mylab,DC=local
83+
IdentityReference : BUILTIN\Pre-Windows 2000 Compatible Access
84+
InheritanceFlags : ContainerInherit
85+
IsInherited : True
86+
PropagationFlags : InheritOnly
87+
ObjectTypeToString : General-Information
88+
InheritedObjectTypeToString : inetOrgPerson
1789
```
1890

19-
- Same as above but using the OU's `DistinguishedName` attribute:
91+
### Get ACLs for all users in an OU with audit rules
92+
93+
Fetches access and audit rules for all users in the `Users` OU, including SACL rules.
2094

2195
```powershell
22-
Get-EffectiveAccess -Identity 'OU=ExampleOU,DC=domainName,DC=com' | Out-GridView
96+
PS /> Get-ADEffectiveAccess -LdapFilter "(objectCategory=person)" -SearchBase "OU=Users,DC=mylab,DC=local" -Audit
2397
```
2498

25-
- Get the _Effective Access_ of the Organizational Unit named `ExampleOU` on a Trusted Domain:
99+
### Pipe AD user object to retrieve ACL
100+
101+
Uses pipeline input from `Get-ADUser` to get effective access rules for the user `jdoe`.
26102

27-
```sh
28-
Get-ADOrganizationalUnit -Filter "Name -eq 'ExampleOU'" -Server trustedDomain |
29-
Get-EffectiveAccess -Server trustedDomain | Out-GridView
103+
```powershell
104+
PS /> Get-ADUser -Identity "jdoe" | Get-ADEffectiveAccess
30105
```
31106

32-
- Store the _Effective Access_ of the group named `exampleGroup` in a variable:
107+
### Get ACLs for deleted groups with a limit
108+
109+
Retrieves access rules for up to 10 deleted group objects.
33110

34111
```powershell
35-
$effectiveAccess = Get-ADGroup exampleGroup | Get-EffectiveAccess
112+
PS /> Get-ADEffectiveAccess -LdapFilter "(&(isDeleted=TRUE)(objectClass=group))" -IncludeDeletedObjects -Top 10
36113
```
37114

38-
- Get the _Effective Access_ of the first 10 OUs found in the Domain:
115+
### Query ACLs with specific credentials
116+
117+
Retrieves access rules for a user using specified credentials.
39118

40119
```powershell
41-
Get-ADOrganizationalUnit -Filter * | Select -First 10 |
42-
Get-EffectiveAccess | Out-GridView
120+
PS /> Get-ADEffectiveAccess -Identity "john.galt" -Credential (Get-Credential)
43121
```
44122

45-
## Sample output with `Out-GridView`
123+
## Changelog
46124

47-
![exampleoutput](/Screenshot/effectiveAccess.png?raw=true)
125+
- [CHANGELOG.md](./CHANGELOG.md)
126+
- [Releases](https://github.com/santisq/ADEffectiveAccess/releases)
48127

49-
## Requirements
128+
## Contributing
50129

51-
- PowerShell v5.1+
52-
- ActiveDirectory PS Module
130+
Contributions are welcome, if you wish to contribute, fork this repository and submit a pull request with the changes.

docs/en-US/Get-ADEffectiveAccess.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ Unlike `Get-Acl`, there is no dependency on the Active Directory module and incl
5454
### Example 1: Get ACL for a specific user by sAMAccountName
5555

5656
```powershell
57-
PS \> Get-ADEffectiveAccess -Identity John.Doe
57+
PS \> Get-ADEffectiveAccess -Identity john.galt
5858
```
5959

60-
Retrieves the effective access rules for the user `John.Doe` in the current domain.
60+
Retrieves the effective access rules for the user `john.galt` in the current domain.
6161

6262
### Example 2: Get ACLs for all users in an OU with audit rules
6363

@@ -91,6 +91,14 @@ PS \> Get-ADEffectiveAccess -LdapFilter "(objectClass=computer)" -Server "myChil
9191

9292
Retrieves access rules for all `computer` objects in a child domain with secure authentication and fast bind.
9393

94+
### Example 6: Query ACLs with specific credentials
95+
96+
Retrieves access rules for a user using specified credentials.
97+
98+
```powershell
99+
PS /> Get-ADEffectiveAccess -Identity "john.galt" -Credential (Get-Credential)
100+
```
101+
94102
## PARAMETERS
95103

96104
### -Audit
@@ -191,7 +199,7 @@ Specifies the AD DS instance to connect to. Accepts:
191199
- Fully qualified domain name
192200
- NetBIOS name
193201
- Directory server name (with optional port, e.g. `myDC01:636`)
194-
- Global Catalog (e.g. `GC://myDomain`)
202+
- Global Catalog (e.g. `GC://myCatalogServer`)
195203

196204
Defaults to the current domain if not specified.
197205

module/ADEffectiveAccess.psd1

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
Copyright = '(c) Santiago Squarzon. All rights reserved.'
3333

3434
# Description of the functionality provided by this module
35-
Description = 'Active Directory friendly ACLs'
35+
Description = 'AD ACLs with readable rights, flexible LDAP and no AD module needed.'
3636

3737
# Minimum version of the PowerShell engine required by this module
3838
PowerShellVersion = '5.1'
@@ -97,7 +97,21 @@
9797
PSData = @{
9898

9999
# Tags applied to this module. These help with module discovery in online galleries.
100-
# Tags = @()
100+
Tags = @(
101+
'powershell',
102+
'csharp',
103+
'activedirectory',
104+
'acl',
105+
'accesscontrol',
106+
'security',
107+
'permissions',
108+
'ldap',
109+
'audit',
110+
'directoryservices',
111+
'ad',
112+
'guidtranslation',
113+
'tombstone'
114+
)
101115

102116
# A URL to the license for this module.
103117
LicenseUri = 'https://github.com/santisq/ADEffectiveAccess/blob/main/LICENSE'

src/ADEffectiveAccess/GuidResolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.DirectoryServices;
4+
using System.Text.RegularExpressions;
45

56
namespace ADEffectiveAccess;
67

@@ -26,6 +27,7 @@ private GuidResolver() { }
2627

2728
internal void SetContext(string? server, DirectoryEntryBuilder builder)
2829
{
30+
if (server is not null) server = Regex.Replace(server, "(?i)GC://", "LDAP://");
2931
using DirectoryEntry rootDSE = builder.Create(server, "RootDSE");
3032
string context = rootDSE.GetRootProperty(DefaultContext);
3133

0 commit comments

Comments
 (0)