fixed bugs

This commit is contained in:
vfedosevich 2013-09-10 18:02:41 +03:00
parent 9dbbd48313
commit ba708deb3a
8 changed files with 265 additions and 71 deletions

View file

@ -2336,7 +2336,7 @@ namespace WebsitePanel.EnterpriseServer
foreach (ExchangeAccount user in securityGroup.MembersAccounts) foreach (ExchangeAccount user in securityGroup.MembersAccounts)
{ {
OrganizationUser userAccount = GetAccountByAccountName(itemId, user.SamAccountName); OrganizationUser userAccount = GetAccountByAccountName(itemId, user.AccountName);
if (userAccount != null) if (userAccount != null)
{ {

View file

@ -255,6 +255,18 @@ namespace WebsitePanel.Providers.HostedSolution
return ret != null ? ret.ToString() : string.Empty; 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) public static string ConvertADPathToCanonicalName(string name)
{ {

View file

@ -928,8 +928,10 @@ namespace WebsitePanel.Providers.HostedSolution
securityGroup.Notes = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes); securityGroup.Notes = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.Notes);
securityGroup.AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName); string samAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
securityGroup.SAMAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(entry, ADAttributes.SAMAccountName);
securityGroup.AccountName = samAccountName;
securityGroup.SAMAccountName = samAccountName;
List<ExchangeAccount> members = new List<ExchangeAccount>(); List<ExchangeAccount> members = new List<ExchangeAccount>();
@ -939,7 +941,7 @@ namespace WebsitePanel.Providers.HostedSolution
members.Add(new ExchangeAccount members.Add(new ExchangeAccount
{ {
AccountName = tmpUser.AccountName, AccountName = ActiveDirectoryUtils.GetCNFromADPath(userPath),
SamAccountName = tmpUser.SamAccountName SamAccountName = tmpUser.SamAccountName
}); });
} }
@ -948,10 +950,12 @@ namespace WebsitePanel.Providers.HostedSolution
{ {
DirectoryEntry groupEntry = ActiveDirectoryUtils.GetADObject(groupPath); DirectoryEntry groupEntry = ActiveDirectoryUtils.GetADObject(groupPath);
string tmpSamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName);
members.Add(new ExchangeAccount members.Add(new ExchangeAccount
{ {
AccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName), AccountName = tmpSamAccountName,
SamAccountName = ActiveDirectoryUtils.GetADObjectStringProperty(groupEntry, ADAttributes.SAMAccountName) SamAccountName = tmpSamAccountName
}); });
} }

View file

@ -45,14 +45,37 @@ namespace WebsitePanel.Portal.ExchangeServer
{ {
public partial class ExchangeDistributionListMemberOf : WebsitePanelModuleBase 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) protected void Page_Load(object sender, EventArgs e)
{ {
groups.SecurityGroupsEnabled = EnableSecurityGroups;
if (!IsPostBack) if (!IsPostBack)
{ {
BindSettings(); BindSettings();
} }
} }
private void BindSettings() private void BindSettings()
@ -67,18 +90,21 @@ namespace WebsitePanel.Portal.ExchangeServer
ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
ExchangeAccount[] secGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
List<ExchangeAccount> groupsList = new List<ExchangeAccount>(); List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
foreach (ExchangeAccount distList in dLists) foreach (ExchangeAccount distList in dLists)
{ {
groupsList.Add(distList); groupsList.Add(distList);
} }
if (EnableSecurityGroups)
{
ExchangeAccount[] secGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in secGroups) foreach (ExchangeAccount secGroup in secGroups)
{ {
groupsList.Add(secGroup); groupsList.Add(secGroup);
} }
}
groups.SetAccounts(groupsList.ToArray()); groups.SetAccounts(groupsList.ToArray());
@ -96,19 +122,25 @@ namespace WebsitePanel.Portal.ExchangeServer
try try
{ {
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>(); IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>();
foreach (ExchangeAccount distList in oldSecGroups)
{
oldGroups.Add(distList);
}
foreach (ExchangeAccount secGroup in oldDistLists) if (EnableSecurityGroups)
{
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in oldSecGroups)
{ {
oldGroups.Add(secGroup); oldGroups.Add(secGroup);
} }
}
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount distList in oldDistLists)
{
oldGroups.Add(distList);
}
IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts(); IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts();
foreach (ExchangeAccount oldGroup in oldGroups) foreach (ExchangeAccount oldGroup in oldGroups)

View file

@ -35,8 +35,33 @@ namespace WebsitePanel.Portal.ExchangeServer
{ {
public partial class ExchangeMailboxMemberOf : WebsitePanelModuleBase 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) protected void Page_Load(object sender, EventArgs e)
{ {
groups.SecurityGroupsEnabled = EnableSecurityGroups;
if (!IsPostBack) if (!IsPostBack)
{ {
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId);
@ -44,9 +69,7 @@ namespace WebsitePanel.Portal.ExchangeServer
BindSettings(); BindSettings();
UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId); UserInfo user = UsersHelper.GetUser(PanelSecurity.EffectiveUserId);
} }
} }
private void BindSettings() private void BindSettings()
@ -59,22 +82,26 @@ namespace WebsitePanel.Portal.ExchangeServer
// title // title
litDisplayName.Text = mailbox.DisplayName; 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<ExchangeAccount> groupsList = new List<ExchangeAccount>(); List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
//Distribution Lists
ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount distList in dLists) foreach (ExchangeAccount distList in dLists)
{ {
groupsList.Add(distList); groupsList.Add(distList);
} }
if (EnableSecurityGroups)
{
//Security Groups
ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in securGroups) foreach (ExchangeAccount secGroup in securGroups)
{ {
groupsList.Add(secGroup); groupsList.Add(secGroup);
} }
}
groups.SetAccounts(groupsList.ToArray()); groups.SetAccounts(groupsList.ToArray());
@ -92,19 +119,24 @@ namespace WebsitePanel.Portal.ExchangeServer
try try
{ {
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>(); IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>();
foreach (ExchangeAccount distList in oldSecGroups)
{
oldGroups.Add(distList);
}
foreach (ExchangeAccount secGroup in oldDistLists) if (EnableSecurityGroups)
{
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in oldSecGroups)
{ {
oldGroups.Add(secGroup); oldGroups.Add(secGroup);
} }
}
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount distList in oldDistLists)
{
oldGroups.Add(distList);
}
IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts(); IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts();
foreach (ExchangeAccount oldGroup in oldGroups) foreach (ExchangeAccount oldGroup in oldGroups)

View file

@ -37,8 +37,41 @@ namespace WebsitePanel.Portal.HostedSolution
{ {
public partial class OrganizationSecurityGroupMemberOf : WebsitePanelModuleBase 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) protected void Page_Load(object sender, EventArgs e)
{ {
groups.DistributionListsEnabled = EnableDistributionLists;
if (!IsPostBack) if (!IsPostBack)
{ {
BindSettings(); BindSettings();
@ -54,22 +87,29 @@ namespace WebsitePanel.Portal.HostedSolution
litDisplayName.Text = group.DisplayName; litDisplayName.Text = group.DisplayName;
List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
if (EnableDistributionLists)
{
//Distribution Lists //Distribution Lists
ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
//Security Groups
ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
foreach (ExchangeAccount distList in dLists) foreach (ExchangeAccount distList in dLists)
{ {
groupsList.Add(distList); groupsList.Add(distList);
} }
}
if (EnableSecurityGroups)
{
//Security Groups
ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in securGroups) foreach (ExchangeAccount secGroup in securGroups)
{ {
groupsList.Add(secGroup); groupsList.Add(secGroup);
} }
}
groups.SetAccounts(groupsList.ToArray()); groups.SetAccounts(groupsList.ToArray());
@ -87,21 +127,30 @@ namespace WebsitePanel.Portal.HostedSolution
try try
{ {
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>();
if (EnableDistributionLists)
{
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>(); foreach (ExchangeAccount distList in oldDistLists)
foreach (ExchangeAccount distList in oldSecGroups)
{ {
oldGroups.Add(distList); oldGroups.Add(distList);
} }
}
foreach (ExchangeAccount secGroup in oldDistLists) if (EnableSecurityGroups)
{
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in oldSecGroups)
{ {
oldGroups.Add(secGroup); oldGroups.Add(secGroup);
} }
}
IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts(); IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts();
foreach (ExchangeAccount oldGroup in oldGroups) foreach (ExchangeAccount oldGroup in oldGroups)
{ {
if (newGroups.ContainsKey(oldGroup.AccountName)) if (newGroups.ContainsKey(oldGroup.AccountName))

View file

@ -37,8 +37,42 @@ namespace WebsitePanel.Portal.HostedSolution
{ {
public partial class UserMemberOf : WebsitePanelModuleBase 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) protected void Page_Load(object sender, EventArgs e)
{ {
groups.DistributionListsEnabled = EnableDistributionLists;
groups.SecurityGroupsEnabled = EnableSecurityGroups;
if (!IsPostBack) if (!IsPostBack)
{ {
BindSettings(); BindSettings();
@ -62,22 +96,29 @@ namespace WebsitePanel.Portal.HostedSolution
litDisplayName.Text = user.DisplayName; litDisplayName.Text = user.DisplayName;
List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
if (EnableDistributionLists)
{
//Distribution Lists //Distribution Lists
ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); ExchangeAccount[] dLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
//Security Groups
ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
List<ExchangeAccount> groupsList = new List<ExchangeAccount>();
foreach (ExchangeAccount distList in dLists) foreach (ExchangeAccount distList in dLists)
{ {
groupsList.Add(distList); groupsList.Add(distList);
} }
}
if (EnableSecurityGroups)
{
//Security Groups
ExchangeAccount[] securGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in securGroups) foreach (ExchangeAccount secGroup in securGroups)
{ {
groupsList.Add(secGroup); groupsList.Add(secGroup);
} }
}
groups.SetAccounts(groupsList.ToArray()); groups.SetAccounts(groupsList.ToArray());
@ -95,21 +136,30 @@ namespace WebsitePanel.Portal.HostedSolution
try try
{ {
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID); IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>();
if (EnableDistributionLists)
{
ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID); ExchangeAccount[] oldDistLists = ES.Services.ExchangeServer.GetDistributionListsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
IList<ExchangeAccount> oldGroups = new List<ExchangeAccount>(); foreach (ExchangeAccount distList in oldDistLists)
foreach (ExchangeAccount distList in oldSecGroups)
{ {
oldGroups.Add(distList); oldGroups.Add(distList);
} }
}
foreach (ExchangeAccount secGroup in oldDistLists) if (EnableSecurityGroups)
{
ExchangeAccount[] oldSecGroups = ES.Services.Organizations.GetSecurityGroupsByMember(PanelRequest.ItemID, PanelRequest.AccountID);
foreach (ExchangeAccount secGroup in oldSecGroups)
{ {
oldGroups.Add(secGroup); oldGroups.Add(secGroup);
} }
}
IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts(); IDictionary<string, ExchangeAccountType> newGroups = groups.GetFullAccounts();
foreach (ExchangeAccount oldGroup in oldGroups) foreach (ExchangeAccount oldGroup in oldGroups)
{ {
if (newGroups.ContainsKey(oldGroup.AccountName)) if (newGroups.ContainsKey(oldGroup.AccountName))
@ -145,7 +195,6 @@ namespace WebsitePanel.Portal.HostedSolution
messageBox.ShowSuccessMessage("ORGANIZATION_UPDATE_USER_SETTINGS"); messageBox.ShowSuccessMessage("ORGANIZATION_UPDATE_USER_SETTINGS");
BindSettings(); BindSettings();
} }
catch (Exception ex) catch (Exception ex)

View file

@ -31,6 +31,7 @@ using System.Collections.Generic;
using WebsitePanel.Portal.Code.UserControls; using WebsitePanel.Portal.Code.UserControls;
using WebsitePanel.WebPortal; using WebsitePanel.WebPortal;
using WebsitePanel.EnterpriseServer; using WebsitePanel.EnterpriseServer;
using WebsitePanel.Providers.HostedSolution;
namespace WebsitePanel.Portal.ExchangeServer.UserControls namespace WebsitePanel.Portal.ExchangeServer.UserControls
{ {
@ -59,8 +60,23 @@ namespace WebsitePanel.Portal.ExchangeServer.UserControls
PackageContext cntx = PackagesHelper.GetCachedPackageContext(PanelSecurity.PackageId); 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")); tabsList.Add(CreateTab("user_memberof", "Tab.MemberOf"));
}
// find selected menu item // find selected menu item
int idx = 0; int idx = 0;