2using System.DirectoryServices.AccountManagement;
3using System.Runtime.Versioning;
4using System.Security.Principal;
6using System.Threading.Tasks;
15 [SupportedOSPlatform(
"windows")]
48 this.identity =
identity ??
throw new ArgumentNullException(nameof(
identity));
80 var newIdentity =
new WindowsIdentity(
identity.Token);
86 throw new InvalidOperationException(
"Cannot clone a UserPrincipal based WindowsSystemIdentity!");
90 public Task
RunImpersonated(Action action, CancellationToken cancellationToken) => Task.Factory.StartNew(
93 ArgumentNullException.ThrowIfNull(action);
95 throw new InvalidOperationException(
"Impersonate using a UserPrincipal based WindowsSystemIdentity!");
96 WindowsIdentity.RunImpersonated(
identity.AccessToken, action);
100 TaskScheduler.Current);
IIOManager that resolves paths to Environment.CurrentDirectory.
const TaskCreationOptions BlockingTaskCreationOptions
The TaskCreationOptions used to spawn Tasks for potentially long running, blocking operations.
ISystemIdentity for windows systems.
readonly WindowsIdentity identity
The WindowsIdentity for the WindowsSystemIdentity.
string Uid
A unique identifier for the user.
WindowsSystemIdentity(WindowsIdentity identity)
Initializes a new instance of the WindowsSystemIdentity class.
string Username
The user's name.
WindowsSystemIdentity(UserPrincipal userPrincipal)
Initializes a new instance of the WindowsSystemIdentity class.
ISystemIdentity Clone()
Clone the ISystemIdentity creating another copy that must have IDisposable.Dispose called on it....
Task RunImpersonated(Action action, CancellationToken cancellationToken)
Runs a given action in the context of the ISystemIdentity. A Task representing the running operation...
readonly UserPrincipal userPrincipal
The UserPrincipal for the WindowsSystemIdentity.
bool CanCreateSymlinks
If this system identity has permissions to create symlinks.
readonly? bool canCreateSymlinks
Backing field for CanCreateSymlinks.
Represents a user on the current global::System.Runtime.InteropServices.OSPlatform.