|
1 | | -# Get-EffectiveAccess |
| 1 | +<h1 align="center">ADEffectiveAccess</h1> |
2 | 2 |
|
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 | +[](https://github.com/santisq/ADEffectiveAccess/actions/workflows/ci.yml) |
| 8 | +[](https://www.powershellgallery.com/packages/ADEffectiveAccess) |
| 9 | +[](https://github.com/santisq/ADEffectiveAccess/blob/main/LICENSE) |
| 10 | + |
| 11 | +</div> |
4 | 12 |
|
5 | 13 | > [!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 |
7 | 35 |
|
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: |
9 | 49 |
|
10 | | -## Examples |
| 50 | +### Get ACL for a specific user by sAMAccountName |
11 | 51 |
|
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. |
13 | 53 |
|
14 | 54 | ```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 |
17 | 89 | ``` |
18 | 90 |
|
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. |
20 | 94 |
|
21 | 95 | ```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 |
23 | 97 | ``` |
24 | 98 |
|
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`. |
26 | 102 |
|
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 |
30 | 105 | ``` |
31 | 106 |
|
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. |
33 | 110 |
|
34 | 111 | ```powershell |
35 | | -$effectiveAccess = Get-ADGroup exampleGroup | Get-EffectiveAccess |
| 112 | +PS /> Get-ADEffectiveAccess -LdapFilter "(&(isDeleted=TRUE)(objectClass=group))" -IncludeDeletedObjects -Top 10 |
36 | 113 | ``` |
37 | 114 |
|
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. |
39 | 118 |
|
40 | 119 | ```powershell |
41 | | -Get-ADOrganizationalUnit -Filter * | Select -First 10 | |
42 | | - Get-EffectiveAccess | Out-GridView |
| 120 | +PS /> Get-ADEffectiveAccess -Identity "john.galt" -Credential (Get-Credential) |
43 | 121 | ``` |
44 | 122 |
|
45 | | -## Sample output with `Out-GridView` |
| 123 | +## Changelog |
46 | 124 |
|
47 | | - |
| 125 | +- [CHANGELOG.md](./CHANGELOG.md) |
| 126 | +- [Releases](https://github.com/santisq/ADEffectiveAccess/releases) |
48 | 127 |
|
49 | | -## Requirements |
| 128 | +## Contributing |
50 | 129 |
|
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. |
0 commit comments