From ff4cdb156cf143a67117aae478102deaa584be68 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 20 Jan 2024 10:44:26 -0500 Subject: [PATCH] Closes #1737 --- src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs index e15b51557d..136c3c24e7 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs @@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Security { this.identity = identity ?? throw new ArgumentNullException(nameof(identity)); if (identity.IsAnonymous) - throw new InvalidOperationException($"Cannot use anonymous {nameof(WindowsIdentity)} as a {nameof(WindowsSystemIdentity)}!"); + throw new ArgumentException($"Cannot use anonymous {nameof(WindowsIdentity)} as a {nameof(WindowsSystemIdentity)}!", nameof(identity)); canCreateSymlinks = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator); } @@ -86,7 +86,7 @@ namespace Tgstation.Server.Host.Security } // can't clone a UP, shouldn't be trying to anyway, cloning is for impersonation - throw new InvalidOperationException("Cannot clone a UserPrincipal based WindowsSystemIdentity!"); + throw new NotSupportedException("Cannot clone a UserPrincipal based WindowsSystemIdentity!"); } /// @@ -95,7 +95,7 @@ namespace Tgstation.Server.Host.Security { ArgumentNullException.ThrowIfNull(action); if (identity == null) - throw new InvalidOperationException("Impersonate using a UserPrincipal based WindowsSystemIdentity!"); + throw new NotSupportedException("Impersonate using a UserPrincipal based WindowsSystemIdentity!"); WindowsIdentity.RunImpersonated(identity.AccessToken, action); }, cancellationToken,