diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs index 7a8f6762..42cd1b20 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/HostedSolution/OrganizationController.cs @@ -2336,7 +2336,7 @@ namespace WebsitePanel.EnterpriseServer foreach (ExchangeAccount user in securityGroup.MembersAccounts) { - OrganizationUser userAccount = GetAccountByAccountName(itemId, user.SamAccountName); + OrganizationUser userAccount = GetAccountByAccountName(itemId, user.AccountName); if (userAccount != null) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs index 27b223eb..ed0332dc 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.Base/HostedSolution/ActiveDirectoryUtils.cs @@ -255,6 +255,18 @@ namespace WebsitePanel.Providers.HostedSolution return ret != null ? ret.ToString() : string.Empty; } + public static string GetCNFromADPath(string path) + { + string[] parts = path.Substring(path.ToUpper().IndexOf("CN=")).Split(','); + + if (parts.Length > 0) + { + return parts[0].Substring(3); + } + + return null; + } + public static string ConvertADPathToCanonicalName(string name) { diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs index 09089959..0bae0a80 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution/OrganizationProvider.cs @@ -928,8 +928,10 @@ namespace WebsitePanel.Providers.HostedSolution securityGroup.Notes = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes); - securityGroup.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName); - securityGroup.SAMAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName); + string samAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName); + + securityGroup.AccountName = samAccountName; + securityGroup.SAMAccountName = samAccountName; List members = new List(); @@ -939,7 +941,7 @@ namespace WebsitePanel.Providers.HostedSolution members.Add(new ExchangeAccount { - AccountName = tmpUser.AccountName, + AccountName = ActiveDirectoryUtils.GetCNFromADPath(userPath), SamAccountName = tmpUser.SamAccountName }); } @@ -948,10 +950,12 @@ namespace WebsitePanel.Providers.HostedSolution { DirectoryEntry groupEntry = ActiveDirectoryUtils.GetADObject(groupPath); + string tmpSamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName); + members.Add(new ExchangeAccount { - AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName), - SamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName) + AccountName = tmpSamAccountName, + SamAccountName = tmpSamAccountName }); } diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDistributionListMemberOf.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDistributionListMemberOf.ascx.cs index ec9a8933..39f21c95 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDistributionListMemberOf.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeDistributionListMemberOf.ascx.cs @@ -45,14 +45,37 @@ namespace WebsitePanel.Portal.ExchangeServer { public partial class ExchangeDistributionListMemberOf : WebsitePanelModuleBase { + protected PackageContext cntx; + + protected PackageContext Cntx + { + get + { + if (cntx == null) + { + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + } + + return cntx; + } + } + + protected bool EnableSecurityGroups + { + get + { + return Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, Cntx); + } + } + protected void Page_Load(object sender, EventArgs e) { + groups.SecurityGroupsEnabled = EnableSecurityGroups; + if (!IsPostBack) { BindSettings(); } - - } private void BindSettings() @@ -67,17 +90,20 @@ namespace WebsitePanel.Portal.ExchangeServer ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - ExchangeAccount[] secGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - List groupsList = new List(); foreach (ExchangeAccount distList in dLists) { groupsList.Add(distList); } - foreach (ExchangeAccount secGroup in secGroups) + if (EnableSecurityGroups) { - groupsList.Add(secGroup); + ExchangeAccount[] secGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in secGroups) + { + groupsList.Add(secGroup); + } } groups.SetAccounts(groupsList.ToArray()); @@ -96,18 +122,24 @@ namespace WebsitePanel.Portal.ExchangeServer try { - ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - IList oldGroups = new List(); - foreach (ExchangeAccount distList in oldSecGroups) + + if (EnableSecurityGroups) { - oldGroups.Add(distList); + ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + + foreach (ExchangeAccount secGroup in oldSecGroups) + { + oldGroups.Add(secGroup); + } } - foreach (ExchangeAccount secGroup in oldDistLists) + ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in oldDistLists) { - oldGroups.Add(secGroup); + oldGroups.Add(distList); } IDictionary newGroups = groups.GetFullAccounts(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxMemberOf.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxMemberOf.ascx.cs index 90250d87..7d80ff2a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxMemberOf.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/ExchangeMailboxMemberOf.ascx.cs @@ -35,8 +35,33 @@ namespace WebsitePanel.Portal.ExchangeServer { public partial class ExchangeMailboxMemberOf : WebsitePanelModuleBase { + protected PackageContext cntx; + + protected PackageContext Cntx + { + get + { + if (cntx == null) + { + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + } + + return cntx; + } + } + + protected bool EnableSecurityGroups + { + get + { + return Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, Cntx); + } + } + protected void Page_Load(object sender, EventArgs e) { + groups.SecurityGroupsEnabled = EnableSecurityGroups; + if (!IsPostBack) { PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); @@ -44,9 +69,7 @@ namespace WebsitePanel.Portal.ExchangeServer BindSettings(); UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); - } - } private void BindSettings() @@ -59,21 +82,25 @@ namespace WebsitePanel.Portal.ExchangeServer // title litDisplayName.Text = mailbox.DisplayName; - //Distribution Lists - ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - - //Security Groups - ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); List groupsList = new List(); + + //Distribution Lists + ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); foreach (ExchangeAccount distList in dLists) { groupsList.Add(distList); } - foreach (ExchangeAccount secGroup in securGroups) + if (EnableSecurityGroups) { - groupsList.Add(secGroup); + //Security Groups + ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in securGroups) + { + groupsList.Add(secGroup); + } } groups.SetAccounts(groupsList.ToArray()); @@ -92,18 +119,23 @@ namespace WebsitePanel.Portal.ExchangeServer try { - ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - IList oldGroups = new List(); - foreach (ExchangeAccount distList in oldSecGroups) + + if (EnableSecurityGroups) { - oldGroups.Add(distList); + ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in oldSecGroups) + { + oldGroups.Add(secGroup); + } } - foreach (ExchangeAccount secGroup in oldDistLists) + ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in oldDistLists) { - oldGroups.Add(secGroup); + oldGroups.Add(distList); } IDictionary newGroups = groups.GetFullAccounts(); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationSecurityGroupMemberOf.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationSecurityGroupMemberOf.ascx.cs index 9b7fc8fa..cd8a0d03 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationSecurityGroupMemberOf.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationSecurityGroupMemberOf.ascx.cs @@ -37,8 +37,41 @@ namespace WebsitePanel.Portal.HostedSolution { public partial class OrganizationSecurityGroupMemberOf : WebsitePanelModuleBase { + protected PackageContext cntx; + + protected PackageContext Cntx + { + get + { + if (cntx == null) + { + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + } + + return cntx; + } + } + + protected bool EnableDistributionLists + { + get + { + return Cntx.Groups.ContainsKey(ResourceGroups.Exchange) & Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, Cntx); + } + } + + protected bool EnableSecurityGroups + { + get + { + return Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, Cntx); + } + } + protected void Page_Load(object sender, EventArgs e) { + groups.DistributionListsEnabled = EnableDistributionLists; + if (!IsPostBack) { BindSettings(); @@ -53,22 +86,29 @@ namespace WebsitePanel.Portal.HostedSolution OrganizationSecurityGroup group = ES.Services.Organizations.GetSecurityGroupGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); litDisplayName.Text = group.DisplayName; - - //Distribution Lists - ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - - //Security Groups - ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); List groupsList = new List(); - foreach (ExchangeAccount distList in dLists) + + if (EnableDistributionLists) { - groupsList.Add(distList); + //Distribution Lists + ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in dLists) + { + groupsList.Add(distList); + } } - foreach (ExchangeAccount secGroup in securGroups) + if (EnableSecurityGroups) { - groupsList.Add(secGroup); + //Security Groups + ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in securGroups) + { + groupsList.Add(secGroup); + } } groups.SetAccounts(groupsList.ToArray()); @@ -87,21 +127,30 @@ namespace WebsitePanel.Portal.HostedSolution try { - ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - IList oldGroups = new List(); - foreach (ExchangeAccount distList in oldSecGroups) + + if (EnableDistributionLists) { - oldGroups.Add(distList); + ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in oldDistLists) + { + oldGroups.Add(distList); + } } - foreach (ExchangeAccount secGroup in oldDistLists) + if (EnableSecurityGroups) { - oldGroups.Add(secGroup); + ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in oldSecGroups) + { + oldGroups.Add(secGroup); + } } IDictionary newGroups = groups.GetFullAccounts(); + foreach (ExchangeAccount oldGroup in oldGroups) { if (newGroups.ContainsKey(oldGroup.AccountName)) 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 72cbe1dc..e5846c99 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserMemberOf.ascx.cs @@ -37,8 +37,42 @@ namespace WebsitePanel.Portal.HostedSolution { public partial class UserMemberOf : WebsitePanelModuleBase { + protected PackageContext cntx; + + protected PackageContext Cntx + { + get + { + if (cntx == null) + { + cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); + } + + return cntx; + } + } + + protected bool EnableDistributionLists + { + get + { + return Cntx.Groups.ContainsKey(ResourceGroups.Exchange) & Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, Cntx); + } + } + + protected bool EnableSecurityGroups + { + get + { + return Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, Cntx); + } + } + protected void Page_Load(object sender, EventArgs e) { + groups.DistributionListsEnabled = EnableDistributionLists; + groups.SecurityGroupsEnabled = EnableSecurityGroups; + if (!IsPostBack) { BindSettings(); @@ -61,22 +95,29 @@ namespace WebsitePanel.Portal.HostedSolution || user.AccountType == ExchangeAccountType.Equipment); litDisplayName.Text = user.DisplayName; - - //Distribution Lists - ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - - //Security Groups - ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); List groupsList = new List(); - foreach (ExchangeAccount distList in dLists) + + if (EnableDistributionLists) { - groupsList.Add(distList); + //Distribution Lists + ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in dLists) + { + groupsList.Add(distList); + } } - foreach (ExchangeAccount secGroup in securGroups) + if (EnableSecurityGroups) { - groupsList.Add(secGroup); + //Security Groups + ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in securGroups) + { + groupsList.Add(secGroup); + } } groups.SetAccounts(groupsList.ToArray()); @@ -95,21 +136,30 @@ namespace WebsitePanel.Portal.HostedSolution try { - ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); - IList oldGroups = new List(); - foreach (ExchangeAccount distList in oldSecGroups) + + if (EnableDistributionLists) { - oldGroups.Add(distList); + ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount distList in oldDistLists) + { + oldGroups.Add(distList); + } } - foreach (ExchangeAccount secGroup in oldDistLists) + if (EnableSecurityGroups) { - oldGroups.Add(secGroup); + ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); + + foreach (ExchangeAccount secGroup in oldSecGroups) + { + oldGroups.Add(secGroup); + } } IDictionary newGroups = groups.GetFullAccounts(); + foreach (ExchangeAccount oldGroup in oldGroups) { if (newGroups.ContainsKey(oldGroup.AccountName)) @@ -145,7 +195,6 @@ namespace WebsitePanel.Portal.HostedSolution messageBox.ShowSuccessMessage("ORGANIZATION_UPDATE_USER_SETTINGS"); - BindSettings(); } catch (Exception ex) diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserTabs.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserTabs.ascx.cs index 99d73a43..4c314966 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserTabs.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/UserControls/UserTabs.ascx.cs @@ -31,6 +31,7 @@ using System.Collections.Generic; using WebsitePanel.Portal.Code.UserControls; using WebsitePanel.WebPortal; using WebsitePanel.EnterpriseServer; +using WebsitePanel.Providers.HostedSolution; namespace WebsitePanel.Portal.ExchangeServer.UserControls { @@ -59,8 +60,23 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); - if (Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, cntx) || Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, cntx)) + bool bSuccess = Utils.CheckQouta(Quotas.ORGANIZATION_SECURITYGROUPMANAGEMENT, cntx); + + if (!bSuccess) + { + // get user settings + OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); + + bSuccess = (Utils.CheckQouta(Quotas.EXCHANGE2007_DISTRIBUTIONLISTS, cntx) + && (user.AccountType == ExchangeAccountType.Mailbox + || user.AccountType == ExchangeAccountType.Room + || user.AccountType == ExchangeAccountType.Equipment)); + } + + if (bSuccess) + { tabsList.Add(CreateTab("user_memberof", "Tab.MemberOf")); + } // find selected menu item int idx = 0;