WindowsLocalGroupClient class

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

public sealed class WindowsLocalGroupClient

Local group membership on the local or an explicit remote computer, through NetAPI and the current Windows identity.

Remarks

Address a group by Sid to stay independent of the UI language. Native calls run off the caller's thread; cancellation before a call starts prevents it, and once a call starts its actual result is returned. Changing membership requires administrative rights on the target computer.

Constructors

WindowsLocalGroupClient

public WindowsLocalGroupClient(string? machineName = null)

Creates a client; null targets the local computer.

Methods

AddMemberAsync

public Task<bool> AddMemberAsync(AccountReference group, AccountReference member, CancellationToken cancellationToken = default)

Adds a member to a local group. Returns false when it already was a member (native 1378), which is not a failure.

Remarks

A group or member that does not exist is AdministrationErrorCategory.NotFound.

EnumerateMembersAsync

public Task<ImmutableArray<LocalGroupMember>> EnumerateMembersAsync(AccountReference group, CancellationToken cancellationToken = default)

Enumerates the direct members of a local group. A missing group is AdministrationErrorCategory.NotFound, never an empty list.

GetGroupNameAsync

public Task<string> GetGroupNameAsync(AccountReference group, CancellationToken cancellationToken = default)

Reads the name of a local group on the target computer, such as "Administratoren" for S-1-5-32-544 on a German Windows.

RemoveMemberAsync

public Task<bool> RemoveMemberAsync(AccountReference group, AccountReference member, CancellationToken cancellationToken = default)

Removes a member from a local group. Returns false when it was not a member (native 1377), which is not a failure.