public sealed class ActiveDirectoryClient Curated Active Directory operations built on explicit, protected LDAP access.
Constructors
ActiveDirectoryClient
public ActiveDirectoryClient(WindowsDirectoryClient directory) Creates a client using a configured directory transport.
Methods
AddMemberAsync
public Task AddMemberAsync(string groupDistinguishedName, string memberDistinguishedName, CancellationToken cancellationToken = default) Adds a group member. An existing value is reported by LDAP as a conflict.
AddServicePrincipalNamesAsync
public Task AddServicePrincipalNamesAsync(string distinguishedName, ImmutableArray<string> names, CancellationToken cancellationToken = default) Adds explicit SPNs; does not generate names or choose an account.
ChangePasswordAsync
public Task ChangePasswordAsync(string distinguishedName, string oldPassword, string newPassword, CancellationToken cancellationToken = default) Changes a password through one LDAP delete/add request, preserving the user's change-password authorization semantics.
CreateComputerAsync
public Task<ActiveDirectoryObjectIdentity> CreateComputerAsync(string parentDistinguishedName, string commonName, string accountName, CancellationToken cancellationToken = default) Creates a disabled workstation computer account and returns its identity. accountName must include its trailing dollar sign.
CreateGroupAsync
public Task<ActiveDirectoryObjectIdentity> CreateGroupAsync(string parentDistinguishedName, string commonName, string accountName, ActiveDirectoryGroupScope scope, bool securityEnabled, CancellationToken cancellationToken = default) Creates a group with explicit scope and security/distribution semantics and returns its identity.
CreateOrganizationalUnitAsync
public Task<ActiveDirectoryObjectIdentity> CreateOrganizationalUnitAsync(string parentDistinguishedName, string name, CancellationToken cancellationToken = default) Creates an organizational unit with an escaped relative name and returns its identity.
CreateUserAsync
public Task<ActiveDirectoryObjectIdentity> CreateUserAsync(string parentDistinguishedName, string commonName, string accountName, string? userPrincipalName = null, CancellationToken cancellationToken = default) Creates a disabled user and returns its identity. Assign a password and enable it explicitly afterward.
Remarks
The object's identity is read on the same connection after it is created. If that read fails, the WindowsAdministrationException has the operation "Read created directory object" and the object exists. The same applies to the other create methods.
GetMembersAsync
public Task<ImmutableArray<string>> GetMembersAsync(string groupDistinguishedName, CancellationToken cancellationToken = default) Retrieves all member DNs, including ranged attributes on large groups.
Remarks
Raw values remain available through WindowsDirectoryClient.ReadAllAttributeValuesAsync.
GetServicePrincipalNamesAsync
public Task<ImmutableArray<string>> GetServicePrincipalNamesAsync(string distinguishedName, CancellationToken cancellationToken = default) Reads all service principal names.
Remarks
Raw values remain available through WindowsDirectoryClient.ReadAllAttributeValuesAsync.
RemoveMemberAsync
public Task RemoveMemberAsync(string groupDistinguishedName, string memberDistinguishedName, CancellationToken cancellationToken = default) Removes a group member. A missing value remains distinguishable as an LDAP error.
RemoveServicePrincipalNamesAsync
public Task RemoveServicePrincipalNamesAsync(string distinguishedName, ImmutableArray<string> names, CancellationToken cancellationToken = default) Removes only explicitly supplied SPNs.
ResetPasswordAsync
public Task ResetPasswordAsync(string distinguishedName, string newPassword, CancellationToken cancellationToken = default) Resets an account password. Requires reset rights; the configured LDAP connection always uses TLS or signing/sealing.
SetAccountEnabledAsync
public Task SetAccountEnabledAsync(string distinguishedName, bool enabled, CancellationToken cancellationToken = default) Enables or disables an account while retaining other control bits and asserting that the observed value has not changed.