> For the complete documentation index, see [llms.txt](https://dudisamarel.gitbook.io/crtp-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dudisamarel.gitbook.io/crtp-notes/ad-enumeration/forests-and-trusts.md).

# Forests and Trusts

Trust is a relationship between two domains or forests which allows trusted domain or forest to access resources in the other domain or forest.

Trust is automatically built or manually established.

## One-way and two-way trusts <a href="#one-way-and-two-way-trusts" id="one-way-and-two-way-trusts"></a>

### One Way

Trust relationships enable access to resources can be either one-way or two-way.\
A one-way trust is a **unidirectional** path between two domains.&#x20;

For example In a one-way trust: \
*Domain A*  <- *Domain B*

*U*sers in ***Domain A*** can access resources in ***Domain B***. However, users in *Domain B* can't access resources in *Domain A*.

### Two Way

In a two-way trust, *Domain A* trusts *Domain B* and *Domain B* trusts *Domain A*.

*U*sers in ***Domain A*** can access resources in ***Domain B*** and, users in *Domain B* can access resources in *Domain A*.

## Transitive and non-transitive trusts <a href="#transitive-and-non-transitive-trusts" id="transitive-and-non-transitive-trusts"></a>

Transitivity determines whether a trust can be extended outside of the two domains with which it was formed.

* A transitive trust can be used to extend trust relationships with other domains.
* A non-transitive trust can be used to deny trust relationships with other domains.

## Defaults

Parent-Child domains will be always two-way transitive.

Tree-Root will always be two way transitive.

<figure><img src="https://1243887971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2u5feZpC62uTNBpZD1mr%2Fuploads%2Fa9cP1cSrdfdLvU6E6KjD%2Ftrust-relationships.png?alt=media&amp;token=9e7e997b-bb77-49de-81b5-9b9f41d91b50" alt=""><figcaption><p>default trust relationship flows</p></figcaption></figure>

## External Trusts

Trust between two domains in different forests when forests do not have a trust relationship. \
Can be one-way or two-way but can't be transitive.

<img src="https://1243887971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2u5feZpC62uTNBpZD1mr%2Fuploads%2F8DodWQWIbkFoYqk1zYjM%2Ffile.excalidraw.svg?alt=media&amp;token=f259bd64-cf79-4dfc-a614-462bd59eae80" alt="" class="gitbook-drawing">

## Forest Trusts

Forest trusts are manually created between two root forests,.

**Important:** Forest trusts can only be created between two forests and can't be implicitly extended to a third forest.

<figure><img src="https://1243887971-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2u5feZpC62uTNBpZD1mr%2Fuploads%2F55Wyl97YmyetvDP1iafW%2Fforest-trusts-diagram.png?alt=media&amp;token=b15aa7f1-2cc9-4579-805f-2bf472598f44" alt=""><figcaption></figcaption></figure>

This example configuration provides the following access:

* Users in *Forest 2* can access resources in any domain in either *Forest 1* or *Forest 3*
* Users in *Forest 3* can access resources in any domain in *Forest 2*
* Users in *Forest 1* can access resources in any domain in *Forest 2*

## Enumeration

{% tabs %}
{% tab title="PowerView" %}
Get a list of all domain trusts for the current domain

```powershell
Get-DomainTrust
Get-DomainTrust -Domain us.dollarcorp.moneycorp.local

# External trusts
Get-DomainTrust | ?{$_.TrustAttributes -eq "FILTER_SIDS"}
```

Get details about the current forest

{% code overflow="wrap" %}

```powershell
Get-Forest
Get-Forest -Forest eurocorp.local
```

{% endcode %}

Get all domains in the current forest

{% code overflow="wrap" %}

```powershell
Get-ForestDomain
Get-ForestDomain -Forest eurocorp.local

```

{% endcode %}

Get all global catalogs for the current forest

```powershell
Get-ForestGlobalCatalog
Get-ForestGlobalCatalog -Forest eurocorp.local
```

Map trusts of a forest&#x20;

```powershell
# External trusts in current forest
Get-ForestDomain | %{Get-DomainTrust -Domain $_.Name} | ?{$_.TrustAttributes -eq "FILTER_SIDS"}

Get-ForestTrust
Get-ForestTrust -Forest eurocorp.local
```

{% endtab %}

{% tab title="AD Module" %}
Get a list of all domain trusts for the current domain

```powershell
Get-ADTrust
Get-ADTrust -Identity us.dollarcorp.moneycorp.local
```

Get details about the current forest

{% code overflow="wrap" %}

```powershell
Get-ADForest
Get-ADForest -Identity eurocorp.local
```

{% endcode %}

Get all domains in the current forest

{% code overflow="wrap" %}

```powershell
(Get-ADForest).Domains
```

{% endcode %}

Get all global catalogs for the current forest

```powershell
Get-ADForest | select -ExpandProperty GlobalCatalogs
```

Map trusts of a forest

```powershell
Get-ADTrust -Filter 'msDS-TrustForestTrustInfo -ne "$null"'
```

{% endtab %}
{% endtabs %}

## References&#x20;

* <https://learn.microsoft.com/en-us/entra/identity/domain-services/concepts-forest-trust>
