From 4d4b6a0606cbde5f26392faa601e6bec0dfc34ec Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 27 Sep 2018 14:03:04 -0400 Subject: [PATCH] Workaround for https://github.com/dotnet/corefx/issues/31841 --- .../Security/WindowsSystemIdentity.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs index deb07e49f9..1cd09cd8c7 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs @@ -62,7 +62,13 @@ namespace Tgstation.Server.Host.Security public ISystemIdentity Clone() { if (identity != null) - return new WindowsSystemIdentity((WindowsIdentity)identity.Clone()); + { + //var newIdentity = (WindowsIdentity)identity.Clone(); //doesn't work because of https://github.com/dotnet/corefx/issues/31841 + + var newIdentity = new WindowsIdentity(identity.Token); //the handle is cloned internally + + return new WindowsSystemIdentity(newIdentity); + } //can't clone a UP, shouldn't be trying to anyway, cloning is for impersonation throw new InvalidOperationException("Cannot clone a UserPrincipal based WindowsSystemIdentity!"); }