From 13f3ffc569ec7a6e6489c5320037b1b6c30ef3e8 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Mon, 5 Jan 2015 05:59:21 -0800 Subject: [PATCH] Central NPS fix --- .../Windows2012.cs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index c845f1ab..77fe591f 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -705,15 +705,22 @@ namespace WebsitePanel.Providers.RemoteDesktopServices var showCmd = new Command("netsh nps show np"); var showResult = ExecuteRemoteShellCommand(runSpace, centralNpshost, showCmd); + var processingOrders = showResult.Where(x => Convert.ToString(x).ToLower().Contains("processing order")).Select(x => Convert.ToString(x)); + var count = 0; - var count = showResult.Count(x => Convert.ToString(x).Contains("policy conf")) + 1001; + foreach(var processingOrder in processingOrders) + { + var order = Convert.ToInt32(processingOrder.Remove(0, processingOrder.LastIndexOf("=") + 1).Replace(" ", "")); + + if (order > count) + { + count = order; + } + } var userGroupAd = ActiveDirectoryUtils.GetADObject(GetUsersGroupPath(organizationId, collectionName)); - var userGroupSid = (byte[])ActiveDirectoryUtils.GetADObjectProperty(userGroupAd, "objectSid"); - - var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count, ConvertByteToStringSid(userGroupSid)); - + var addCmdString = string.Format(AddNpsString, policyName.Replace(" ", "_"), count + 1, ConvertByteToStringSid(userGroupSid)); Command addCmd = new Command(addCmdString); var result = ExecuteRemoteShellCommand(runSpace, centralNpshost, addCmd);