From ddcd9ca2db739494e7d30d2ece4a587485acef18 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Thu, 21 May 2015 03:45:55 -0700 Subject: [PATCH] Logging collections import --- .../RemoteDesktopServicesController.cs | 2 +- .../Windows2012.cs | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs index ba91ef4a..7c75150a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/RemoteDesktopServices/RemoteDesktopServicesController.cs @@ -343,7 +343,7 @@ namespace WebsitePanel.EnterpriseServer private static ResultObject ImportCollectionInternal(int itemId, string collectionName) { - var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "SHADOW_RDS_SESSION"); + var result = TaskManager.StartResultTask("REMOTE_DESKTOP_SERVICES", "IMPORT_RDS_COLLECTION"); try { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs index dd287158..3d4e959d 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.TerminalServices.Windows2012/Windows2012.cs @@ -1702,6 +1702,7 @@ namespace WebsitePanel.Providers.RemoteDesktopServices try { + Log.WriteStart(string.Format("Starting collection import: {0}", collection.Name)); runSpace = OpenRunspace(); var orgPath = GetOrganizationPath(organizationId); CheckOrCreateAdGroup(GetComputerGroupPath(organizationId, collection.Name), orgPath, GetComputersGroupName(collection.Name), RdsCollectionComputersGroupDescription); @@ -1742,7 +1743,10 @@ namespace WebsitePanel.Providers.RemoteDesktopServices MoveSessionHostToCollectionOU(rdsServer.Name, collection.Name, organizationId); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, helpDeskGroupSamAccountName); AddAdGroupToLocalAdmins(runSpace, rdsServer.FqdName, localAdminsGroupSamAccountName); + + Log.WriteStart(string.Format("Adding server {0} to AD Group, OrgId: {1}", rdsServer.Name, organizationId)); AddComputerToCollectionAdComputerGroup(organizationId, collection.Name, rdsServer); + Log.WriteStart(string.Format("Server {0} added to AD Group, OrgId: {1}", rdsServer.Name, organizationId)); } string collectionComputersPath = GetComputerGroupPath(organizationId, collection.Name); @@ -1753,6 +1757,8 @@ namespace WebsitePanel.Providers.RemoteDesktopServices CreateHelpDeskPolicy(runSpace, new DirectoryEntry(GetHelpDeskGroupPath(RDSHelpDeskGroup)), new DirectoryEntry(collectionComputersPath), organizationId, collection.Name); SetUsersInCollection(organizationId, collection.Name, users); + + Log.WriteStart(string.Format("Collection imported: {0}", collection.Name)); } finally { @@ -1849,23 +1855,36 @@ namespace WebsitePanel.Providers.RemoteDesktopServices private void AddComputerToCollectionAdComputerGroup(string organizationId, string collectionName, RdsServer server) { - var computerGroupName = GetComputersGroupName( collectionName); + var computerGroupName = GetComputersGroupName( collectionName); var computerObject = GetComputerObject(server.Name); + Log.WriteStart(string.Format("ComputerGroupName: {0}\r\nServerName: {1}\r\nCollectionName: {2}", computerGroupName, server.Name, collectionName)); + if (computerObject != null) { var samName = (string)ActiveDirectoryUtils.GetADObjectProperty(computerObject, "sAMAccountName"); + Log.WriteStart(string.Format("sAMAccountName: {0}\r\nPath: {1}\r\n", samName, computerObject.Path)); if (!ActiveDirectoryUtils.IsComputerInGroup(samName, computerGroupName)) { - ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, GetComputerGroupPath(organizationId, collectionName)); + string groupPath = GetComputerGroupPath(organizationId, collectionName); + Log.WriteStart(string.Format("ComputerGroupPath: {0}", groupPath)); + ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, groupPath); + Log.WriteStart(string.Format("{0} added to {1}", computerObject.Path, groupPath)); } if (!ActiveDirectoryUtils.IsComputerInGroup(samName, RDSHelpDeskComputerGroup)) { - ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, GetHelpDeskGroupPath(RDSHelpDeskComputerGroup)); + string helpDeskGroupPath = GetHelpDeskGroupPath(RDSHelpDeskComputerGroup); + Log.WriteStart(string.Format("HelpDeskGroupPath: {0}", helpDeskGroupPath)); + ActiveDirectoryUtils.AddObjectToGroup(computerObject.Path, helpDeskGroupPath); + Log.WriteStart(string.Format("{0} added to {1}", computerObject.Path, helpDeskGroupPath)); } } + else + { + Log.WriteStart(string.Format("ComputerObject IS NULL")); + } SetRDServerNewConnectionAllowed(false, server); }