From dc59d2fdbb2c9633adc895d5491e54e5925dc642 Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 2 Oct 2013 16:53:37 +0300 Subject: [PATCH 1/2] fixed bugs --- .../ExchangeServer/ExchangeServerController.cs | 3 +-- .../HostedSolution/OrganizationController.cs | 15 ++++++++++++++- .../HostedSolution/ActiveDirectoryUtils.cs | 4 ++++ .../Exchange2013.cs | 18 ++++++++++++++++++ .../Exchange2007.cs | 18 ++++++++++++++++++ .../OrganizationProvider.cs | 14 +++++++++----- .../OrganizationUserMemberOf.ascx.cs | 2 +- 7 files changed, 65 insertions(+), 9 deletions(-) diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs index 1513a736..dc6de57b 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/ExchangeServer/ExchangeServerController.cs @@ -3993,8 +3993,7 @@ namespace WebsitePanel.EnterpriseServer List DistributionLists = GetAccounts(itemId, ExchangeAccountType.DistributionList); foreach (ExchangeAccount DistributionAccount in DistributionLists) { - //ExchangeDistributionList DistributionList = exchange.GetDistributionListGeneralSettings(DistributionAccount.AccountName); - OrganizationSecurityGroup DistributionList = OrganizationController.GetSecurityGroupGeneralSettings(itemId, DistributionAccount.AccountId); + ExchangeDistributionList DistributionList = exchange.GetDistributionListGeneralSettings(DistributionAccount.AccountName); foreach (ExchangeAccount member in DistributionList.MembersAccounts) { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs index e3950463..e3c9d25a 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs @@ -2704,18 +2704,31 @@ namespace WebsitePanel.EnterpriseServer #endregion + // load organization + Organization org = (Organization)PackageController.GetPackageItem(itemId); + if (org == null) + return null; + string accountTypes = string.Format("{0}", ((int)ExchangeAccountType.SecurityGroup)); if (!includeOnlySecurityGroups) { - accountTypes = string.Format("{0}, {1}, {2}, {3}, {4}, {5}", accountTypes, ((int)ExchangeAccountType.User), ((int)ExchangeAccountType.Mailbox), + accountTypes = string.Format("{0}, {1}", accountTypes, ((int)ExchangeAccountType.User)); + + int exchangeServiceId = PackageController.GetPackageServiceId(org.PackageId, ResourceGroups.Exchange); + + if (exchangeServiceId != 0) + { + accountTypes = string.Format("{0}, {1}, {2}, {3}, {4}", accountTypes, ((int)ExchangeAccountType.Mailbox), ((int)ExchangeAccountType.Room), ((int)ExchangeAccountType.Equipment), ((int)ExchangeAccountType.DistributionList)); + } } List tmpAccounts = ObjectUtils.CreateListFromDataReader( DataProvider.SearchExchangeAccountsByTypes(SecurityContext.User.UserId, itemId, accountTypes, filterColumn, filterValue, sortColumn)); + List accounts = new List(); foreach (ExchangeAccount tmpAccount in tmpAccounts.ToArray()) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs index ed0332dc..1e5abee9 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs @@ -399,6 +399,8 @@ namespace WebsitePanel.Providers.HostedSolution DirectoryEntry group = new DirectoryEntry(groupPath); group.Invoke("Add", obj.Path); + + group.CommitChanges(); } public static void RemoveObjectFromGroup(string obejctPath, string groupPath) @@ -407,6 +409,8 @@ namespace WebsitePanel.Providers.HostedSolution DirectoryEntry group = new DirectoryEntry(groupPath); group.Invoke("Remove", obj.Path); + + group.CommitChanges(); } public static bool AdObjectExists(string path) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs index 94c4ebe7..021b1bbc 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -4016,7 +4016,25 @@ namespace WebsitePanel.Providers.HostedSolution id = GetPSObjectIdentity(obj); account = GetExchangeAccount(runSpace, id); if (account != null) + { list.Add(account); + } + else + { + string distinguishedName = (string)GetPSObjectProperty(obj, "DistinguishedName"); + string path = ActiveDirectoryUtils.AddADPrefix(distinguishedName, PrimaryDomainController); + + if (ActiveDirectoryUtils.AdObjectExists(path)) + { + DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path); + + list.Add(new ExchangeAccount + { + AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName), + AccountType = ExchangeAccountType.SecurityGroup + }); + } + } } ExchangeLog.LogEnd("GetGroupMembers"); return list.ToArray(); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs index 7197eb88..481509f5 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -3771,7 +3771,25 @@ namespace WebsitePanel.Providers.HostedSolution id = GetPSObjectIdentity(obj); account = GetExchangeAccount(runSpace, id); if (account != null) + { list.Add(account); + } + else + { + string distinguishedName = (string)GetPSObjectProperty(obj, "DistinguishedName"); + string path = ActiveDirectoryUtils.AddADPrefix(distinguishedName, PrimaryDomainController); + + if (ActiveDirectoryUtils.AdObjectExists(path)) + { + DirectoryEntry entry = ActiveDirectoryUtils.GetADObject(path); + + list.Add(new ExchangeAccount + { + AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName), + AccountType = ExchangeAccountType.SecurityGroup + }); + } + } } ExchangeLog.LogEnd("GetGroupMembers"); return list.ToArray(); diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index 0bae0a80..68c774e3 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -1015,12 +1015,18 @@ namespace WebsitePanel.Providers.HostedSolution ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes); - foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user")) + entry.CommitChanges(); + + string orgPath = GetOrganizationPath(organizationId); + + DirectoryEntry orgEntry = ActiveDirectoryUtils.GetADObject(orgPath); + + foreach (string userPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "user", orgEntry)) { ActiveDirectoryUtils.RemoveObjectFromGroup(userPath, path); } - foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group")) + foreach (string groupPath in ActiveDirectoryUtils.GetGroupObjects(groupName, "group", orgEntry)) { ActiveDirectoryUtils.RemoveObjectFromGroup(groupPath, path); } @@ -1029,9 +1035,7 @@ namespace WebsitePanel.Providers.HostedSolution { string objPath = GetObjectPath(organizationId, obj); ActiveDirectoryUtils.AddObjectToGroup(objPath, path); - } - - entry.CommitChanges(); + } } public void AddObjectToSecurityGroup(string organizationId, string accountName, string groupName) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs index e5846c99..944db3e3 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs @@ -90,7 +90,7 @@ namespace WebsitePanel.Portal.HostedSolution // get settings OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); - groups.DistributionListsEnabled = (user.AccountType == ExchangeAccountType.Mailbox + groups.DistributionListsEnabled = EnableDistributionLists && (user.AccountType == ExchangeAccountType.Mailbox || user.AccountType == ExchangeAccountType.Room || user.AccountType == ExchangeAccountType.Equipment); From a1f10d631e26134a6d580424b368d7072dce76f4 Mon Sep 17 00:00:00 2001 From: Virtuworks Date: Wed, 2 Oct 2013 11:06:47 -0400 Subject: [PATCH 2/2] Added tag build-2.1.0.179 for changeset 1beaff5360e6