WindowsDomainClient class

Namespace Runic.Platform.Administration.Windows.DirectoryServices in Runic.Platform.Administration.Windows 0.23.0

public sealed class WindowsDomainClient

Native machine membership and controller discovery, without ADSI.

Remarks

Native NetAPI and DC-locator calls run off the caller's thread. Cancellation before a call starts prevents it; once a call starts, its actual result is returned.

Constructors

WindowsDomainClient

public WindowsDomainClient(string? machineName = null)

Creates a client for the local computer, or an explicit remote computer.

Methods

DiscoverControllerAsync

public Task<DomainControllerInfo> DiscoverControllerAsync(string? domainName = null, bool requirePrimary = false, bool requireWritable = true, CancellationToken cancellationToken = default)

Discovers a DNS-named directory controller, with optional primary-controller and writable requirements.

Remarks

Discovery can block for the DC locator's network timeouts.

DiscoverControllerAsync

public Task<DomainControllerInfo> DiscoverControllerAsync(string? domainName, bool requirePrimary, bool requireWritable, DomainControllerNameFormat nameFormat, CancellationToken cancellationToken = default)

Discovers a directory controller and returns its names in the requested form.

Remarks

With DomainControllerNameFormat.Flat, DomainControllerInfo.Name is the controller's NetBIOS name (as Win32_NTDomain.DomainControllerName reported it) and DomainControllerInfo.DomainName the domain's flat name. Each call is one locator query, so two calls with different formats can return different controllers. Discovery can block for the DC locator's network timeouts.

GetMembershipAsync

public Task<DomainMembership> GetMembershipAsync(CancellationToken cancellationToken = default)

Reads join state and domain role; a workgroup is a successful result, not a failed domain query.