From 3f10503dfe6ad651aeb3dc1837085c42d428e04f Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Mon, 7 Jul 2014 03:28:22 +0300 Subject: [PATCH] fixed bug with details in the GPO Settings tab. --- .../HostedSolution/ActiveDirectoryUtils.cs | 14 ++++++++++++++ .../OrganizationProvider.cs | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs index 96a069de..447512ad 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs @@ -91,6 +91,20 @@ namespace WebsitePanel.Providers.HostedSolution return rets.ToArray(); } + public static DirectoryEntry GetGroupPolicyContainer(string displayName) + { + DirectorySearcher deSearch = new DirectorySearcher + { + Filter = + ("(&(objectClass=groupPolicyContainer)(displayName=" + displayName + "))") + }; + + SearchResult results = deSearch.FindOne(); + DirectoryEntry de = results.GetDirectoryEntry(); + + return de; + } + public static bool IsUserInGroup(string samAccountName, string group) { bool res = false; diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index 6480b959..b1440ba1 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -53,6 +53,7 @@ namespace WebsitePanel.Providers.HostedSolution private const string GROUP_POLICY_MAPPED_DRIVES_FILE_PATH_TEMPLATE = @"\\{0}\SYSVOL\{0}\Policies\{1}\User\Preferences\Drives"; private const string DRIVES_CLSID = "{8FDDCC1A-0C3C-43cd-A6B4-71A6DF20DA8C}"; private const string DRIVE_CLSID = "{935D1B74-9CB8-4e3c-9914-7DD559B7A417}"; + private const string gPCUserExtensionNames = "[{00000000-0000-0000-0000-000000000000}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}][{5794DAFD-BE60-433F-88A2-1A31939AC01F}{2EA1A81B-48E5-45E9-8BB7-A6E3AC170006}]"; #endregion @@ -1582,9 +1583,25 @@ namespace WebsitePanel.Providers.HostedSolution } } + if (drives.Length == 0 && newDrive) + { + SetGPCUserExtensionNames(organizationId); + } + return exists; } + private void SetGPCUserExtensionNames(string organizationId) + { + string gpoName = string.Format("{0}-mapped-drives", organizationId); + + DirectoryEntry de = ActiveDirectoryUtils.GetGroupPolicyContainer(gpoName); + + ActiveDirectoryUtils.SetADObjectProperty(de, "gPCUserExtensionNames", gPCUserExtensionNames); + + de.CommitChanges(); + } + #region Drive Mapping Helpers private void CreateDrivesXmlEmpty(string path, string fileName)