From a119457462e61377d840989c25c870cc571c24b3 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 6 Nov 2017 11:47:45 -0500 Subject: [PATCH 1/2] Fixes remote logins disallowing Windows impersonation --- TGServiceInterface/Interface.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/TGServiceInterface/Interface.cs b/TGServiceInterface/Interface.cs index 57e024527e..57488c1467 100644 --- a/TGServiceInterface/Interface.cs +++ b/TGServiceInterface/Interface.cs @@ -341,6 +341,7 @@ namespace TGServiceInterface { res.Credentials.UserName.UserName = HTTPSUsername; res.Credentials.UserName.Password = HTTPSPassword; + res.Credentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; } return res; } From 4a85095f7a9440cd6c80ad55444f1779eb1621d2 Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Mon, 6 Nov 2017 12:06:02 -0500 Subject: [PATCH 2/2] Adds regression test for remote impersonation --- TGServiceTests/Interface/TestInterface.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/TGServiceTests/Interface/TestInterface.cs b/TGServiceTests/Interface/TestInterface.cs index dafa7270db..ebb8ec3751 100644 --- a/TGServiceTests/Interface/TestInterface.cs +++ b/TGServiceTests/Interface/TestInterface.cs @@ -1,6 +1,8 @@ using System; using System.Net; +using System.ServiceModel; using Microsoft.VisualStudio.TestTools.UnitTesting; +using TGServiceInterface.Components; namespace TGServiceInterface.Tests { @@ -10,6 +12,10 @@ namespace TGServiceInterface.Tests [TestClass] public class TestInterface { + /// + /// Name to use for testing s + /// + const string TestInstanceName = "TestInstance"; /// /// Test that can execute successfully /// @@ -76,5 +82,14 @@ namespace TGServiceInterface.Tests Assert.AreEqual(first.HTTPSPort, second.HTTPSPort); Assert.IsTrue(second.IsRemoteConnection); } + + [TestMethod] + public void TestRemoteAccessInterfaceAllowsWindowsImpersonation() + { + var inter = CreateFakeRemoteInterface(); + var po = new PrivateObject(inter); + var cf = (ChannelFactory)po.Invoke("CreateChannel", new Type[] { typeof(string) }, new object[] { TestInstanceName }, new Type[] { typeof(ITGConfig) }); + Assert.AreEqual(cf.Credentials.Windows.AllowedImpersonationLevel, System.Security.Principal.TokenImpersonationLevel.Impersonation); + } } }