---
title: ActiveDirectoryServiceProxy
summary: API reference for ActiveDirectoryServiceProxy.
status: draft
owner: SAIF.Core Documentation Team
last_reviewed: 2026-09-24
library: SAIF.Services.Web.Proxies
reference_type: package
---

# ActiveDirectoryServiceProxy

`ActiveDirectoryServiceProxy` hides the internal generated `clsADServicesSoapClient` behind three intention-revealing operations — default printer lookup, cached role-access checks, and a mapped contact record — for callers that need Active Directory data without depending on the wire-level SOAP client directly. It has no in-repository caller and is reachable only by package consumers*.

## Purpose
- Retrieve a user's default printer from Active Directory ([OP-WP-01](../../operations/get-active-directory-user-data-or-access.md)).
- Answer a cached role-access decision, choosing the external or internal cache lookup based on the caller's domain flag ([WP-BR-002](../../business-rules.md#wp-br-002-access-check-selects-internal-or-external-cache)).
- Map a raw AD `USERINFOSTRUCT` into a `SAIF.Core.Contracts.Contact`, normalizing null fields to empty strings ([WP-BR-003](../../business-rules.md#wp-br-003-null-ad-attributes-become-empty-strings)).

## Context
- Namespace: `SAIF.Services.Web.Proxies`
- Assembly/package: `SAIF.Services.Web.Proxies` (packaged in `SAIF.SAIFCode.Core`)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| Constructor | `ActiveDirectoryServiceProxy(string serviceUrl)` | Guards `serviceUrl` is non-null/non-empty, then builds a default `BasicHttpBinding` client and `EndpointAddress(serviceUrl)` in code, bypassing `app.config` ([WP-BR-001](../../business-rules.md#wp-br-001-required-arguments-must-be-non-null-or-non-empty)) |
| `GetDefaultPrinter` | `string GetDefaultPrinter(string userId)` | Guards `userId`, then returns the AD user's default printer name from the wire `GetDefaultPrinter` operation |
| `HasAccess` | `bool HasAccess(string userId, string role, bool useExternalDomain)` | Returns whether the user has the given role, using the external-domain cache when `useExternalDomain` is true and the internal cache otherwise ([WP-BR-002](../../business-rules.md#wp-br-002-access-check-selects-internal-or-external-cache)) |
| `GetContact` | `Contact GetContact(string userId)` | Retrieves the AD user's address, fax, name, telephone, email, and gender, mapped into a `Contact` with null fields coalesced to empty strings ([WP-BR-003](../../business-rules.md#wp-br-003-null-ad-attributes-become-empty-strings)) |
| `Dispose` | `void Dispose()` | Closes the underlying generated `clsADServicesSoapClient` by calling `Close()`, without an `Abort()` fallback on a faulted channel* |

## Behavioral notes
- `GetContact` has no null guard on `userId`, and a null `userInfo` returned by the wire call throws `NullReferenceException`*.
- No in-repository code constructs this wrapper; its consumers are outside this repository**.

## Constraints and usage notes
- Callers must supply a valid `serviceUrl`; this wrapper does not read configuration for its own endpoint.
- The generated client uses a default, unsecured `BasicHttpBinding`; whether the transport is HTTPS depends only on the URL scheme the caller supplies.

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- `Services/SAIF.Services.Web.Proxies/ActiveDirectoryServiceProxy.cs`
