---
title: Resolve host
summary: OP-07 operation detail page.
status: draft
owner: Framework.NCore maintainers
last_reviewed: 2026-10-02
library: SAIF.NetCore.EnvironmentClient
reference_type: package
---

# Resolve host

| Field | Value |
| --- | --- |
| Owner | `HostResolver.ResolveHost` (implements `IHostResolver`) |
| Trigger | Step 5 of [Initialize environment client](initialize-environment-client.md) |
| Inputs | The distinct set of hosts collected from all tracks returned by the Environment API |
| Outputs | `HostResolver.Host`, `HostResolver.AppConfigOverride` |

## Steps
1. Call `IsConfigOverrideAllowed`: read `AppSettings:EnvApiDeveloperOverrideAllowed`. If the value is empty/unset, the override is allowed by default (`checkOverride` starts `true`). If non-empty, `bool.TryParse` is used: a valid `"true"`/`"false"` string sets `checkOverride` accordingly, but a **malformed** (non-boolean) string makes `bool.TryParse` fail and leaves `checkOverride` at its output default of `false` — malformed values are treated the same as an explicit `false`, not as "allowed". If `checkOverride` is `true`, the AD group membership check runs: a `PrincipalContext(ContextType.Domain)` is opened and the machine's computer account is looked up alongside the `Developer_Machine_Users` group (see [security and authorization, AD resource catalog](../security-authorization.md#ad-resource-catalog)) ([BR-EC-04](../business-rules.md#br-ec-04-a-config-file-host-override-requires-ad-override-permission-and-group-membership)). None of this AD access is wrapped in a `try`/`catch` in `HostResolver`: a domain-connectivity failure or any other exception from `PrincipalContext`/`ComputerPrincipal.FindByIdentity`/`GroupPrincipal.FindByIdentity` propagates uncaught out of `IsConfigOverrideAllowed`, `ResolveHost`, and ultimately `Setup()`/the constructor, rather than resolving to `false` or being translated into an `EnvironmentClientException`. Only a **successful** lookup that returns `null` for either principal, or finds the computer is not a group member, denies the override without throwing.
2. If the override is allowed and `AppSettings:ApplicationHost` is non-empty, set `Host = ApplicationHost` (lower-cased) and `AppConfigOverride = true` ([BR-EC-05](../business-rules.md#br-ec-05-a-non-empty-applicationhost-override-sets-the-host-and-marks-appconfigoverride)).
3. Otherwise, derive the host from the content-root path: split `IHostEnvironment.ContentRootPath` and look for a path segment that matches one of the candidate hosts (case-insensitive) ([BR-EC-06](../business-rules.md#br-ec-06-otherwise-the-host-is-inferred-from-the-content-root-path)).
4. If no path segment matches, fall back to `Environment.MachineName` (lower-cased) as the host ([BR-EC-07](../business-rules.md#br-ec-07-otherwise-the-host-defaults-to-the-machine-name)).
5. `AppConfigOverride` is only ever assigned inside `TryResolveHostFromAppConfig`, which runs only when `IsConfigOverrideAllowed()` returns `true`. When the override is allowed, `TryResolveHostFromAppConfig` always assigns `AppConfigOverride` (`true` if `ApplicationHost` is non-empty, `false` otherwise). When the override is **not** allowed, `TryResolveHostFromAppConfig` never runs and `AppConfigOverride` is left untouched — it remains at its constructor-initialized `false`, or, if `HostResolver` is reused across multiple `ResolveHost` calls, at whatever value a prior allowed call left it. There is no unconditional reset to `false` on the non-override path.

## Process flow

```mermaid
flowchart TD
    A[ResolveHost candidateHosts] --> B["IsConfigOverrideAllowed:<br>EnvApiDeveloperOverrideAllowed + AD group check"]
    B -->|allowed| G{ApplicationHost config value set?}
    G -->|Yes| C["Host = ApplicationHost<br>AppConfigOverride = true"]
    G -->|No| H["AppConfigOverride = false"]
    B -->|not allowed| D{"Content-root path<br>segment matches a host?"}
    H --> D
    D -- Yes --> E["Host = matched segment<br>(AppConfigOverride unchanged)"]
    D -- No --> F["Host = MachineName<br>(AppConfigOverride unchanged)"]
```

## Sources
- `src/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/HostResolver.cs`
- `src/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/SystemWrapper.cs`
