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 6ccd3d70..481f4059 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs @@ -2719,18 +2719,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 3eb7793c..0557d347 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.Exchange2013/Exchange2013.cs @@ -4041,7 +4041,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 0b9c554b..4f7c3527 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/Exchange2007.cs @@ -3796,7 +3796,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 3b46d193..7fb2a099 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -1024,12 +1024,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); } @@ -1038,9 +1044,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);