public sealed class WindowsDirectoryClient : IDisposable Explicit LDAP operations with typed values and no ADSI runtime COM dependency.
Remarks
Each operation opens and binds its own connection unless DirectoryConnectionOptions.ReuseConnection is set; then the client keeps one connection and runs its operations one at a time. Dispose a reusing client to close its connection. Cross-operation transactions and automatic retries are not provided. Read values are typed by the attribute's schema syntax: string syntaxes are Text; octet-string, SID and security-descriptor syntaxes, and attributes the schema does not define, are Binary. RootDSE values are text. The client caches the syntaxes it has read.
Constructors
WindowsDirectoryClient
public WindowsDirectoryClient(DirectoryConnectionOptions options, NetworkCredential? credential = null) Creates a directory client. Explicit credentials are retained privately and never included in diagnostic models.
Methods
CreateAsync
public Task CreateAsync(string distinguishedName, ImmutableDictionary<string, ImmutableArray<DirectoryValue>> attributes, CancellationToken cancellationToken = default) Creates an object. objectClass and all required schema attributes must be supplied explicitly.
DeleteAsync
public Task<bool> DeleteAsync(string distinguishedName, CancellationToken cancellationToken = default) Deletes a single object without recursive deletion. Returns false only if absent.
Dispose
public void Dispose() Closes the reused connection, if any. Later operations throw ObjectDisposedException.
Remarks
An operation that is running finishes first; the connection closes when it completes. A client without DirectoryConnectionOptions.ReuseConnection holds no connection between operations.
FindAsync
public Task<DirectoryObject?> FindAsync(string distinguishedName, ImmutableArray<string> attributes, CancellationToken cancellationToken = default) Reads an object by distinguished name; null means no such object.
ModifyAsync
public Task ModifyAsync(string distinguishedName, ImmutableArray<DirectoryModification> modifications, CancellationToken cancellationToken = default) Applies explicit LDAP modifications in one server request.
MoveAsync
public Task MoveAsync(string distinguishedName, string newParentDistinguishedName, string newRdn, CancellationToken cancellationToken = default) Renames or moves an object. newRdn must be a complete escaped relative distinguished name.
ReadAllAttributeValuesAsync
public Task<ImmutableArray<DirectoryValue>> ReadAllAttributeValuesAsync(string distinguishedName, string attributeName, CancellationToken cancellationToken = default) Retrieves every range of a large multi-valued AD attribute without confusing it with LDAP search paging.
ReadRootDseAsync
public Task<DirectoryObject?> ReadRootDseAsync(ImmutableArray<string> attributes, CancellationToken cancellationToken = default) Reads selected RootDSE attributes from the configured server.
Remarks
Every RootDSE value is returned as Text without a schema lookup: the schema's location is itself a RootDSE attribute, and Active Directory defines RootDSE values as strings.
SearchAsync
public Task<ImmutableArray<DirectoryObject>> SearchAsync(DirectorySearch search, CancellationToken cancellationToken = default) Performs a paged search. Cancellation is checked between bounded native requests; server failures never return partial success.