fixed bugs

This commit is contained in:
vfedosevich 2013-10-02 16:53:37 +03:00
parent 789f1402a6
commit dc59d2fdbb
7 changed files with 65 additions and 9 deletions

View file

@ -3993,8 +3993,7 @@ namespace WebsitePanel.EnterpriseServer
List<ExchangeAccount> DistributionLists = GetAccounts(itemId, ExchangeAccountType.DistributionList); List<ExchangeAccount> DistributionLists = GetAccounts(itemId, ExchangeAccountType.DistributionList);
foreach (ExchangeAccount DistributionAccount in DistributionLists) foreach (ExchangeAccount DistributionAccount in DistributionLists)
{ {
//ExchangeDistributionList DistributionList = exchange.GetDistributionListGeneralSettings(DistributionAccount.AccountName); ExchangeDistributionList DistributionList = exchange.GetDistributionListGeneralSettings(DistributionAccount.AccountName);
OrganizationSecurityGroup DistributionList = OrganizationController.GetSecurityGroupGeneralSettings(itemId, DistributionAccount.AccountId);
foreach (ExchangeAccount member in DistributionList.MembersAccounts) foreach (ExchangeAccount member in DistributionList.MembersAccounts)
{ {

View file

@ -2704,18 +2704,31 @@ namespace WebsitePanel.EnterpriseServer
#endregion #endregion
// load organization
Organization org = (Organization)PackageController.GetPackageItem(itemId);
if (org == null)
return null;
string accountTypes = string.Format("{0}", ((int)ExchangeAccountType.SecurityGroup)); string accountTypes = string.Format("{0}", ((int)ExchangeAccountType.SecurityGroup));
if (!includeOnlySecurityGroups) 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)); ((int)ExchangeAccountType.Room), ((int)ExchangeAccountType.Equipment), ((int)ExchangeAccountType.DistributionList));
}
} }
List<ExchangeAccount> tmpAccounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>( List<ExchangeAccount> tmpAccounts = ObjectUtils.CreateListFromDataReader<ExchangeAccount>(
DataProvider.SearchExchangeAccountsByTypes(SecurityContext.User.UserId, itemId, DataProvider.SearchExchangeAccountsByTypes(SecurityContext.User.UserId, itemId,
accountTypes, filterColumn, filterValue, sortColumn)); accountTypes, filterColumn, filterValue, sortColumn));
List<ExchangeAccount> accounts = new List<ExchangeAccount>(); List<ExchangeAccount> accounts = new List<ExchangeAccount>();
foreach (ExchangeAccount tmpAccount in tmpAccounts.ToArray()) foreach (ExchangeAccount tmpAccount in tmpAccounts.ToArray())

View file

@ -399,6 +399,8 @@ namespace WebsitePanel.Providers.HostedSolution
DirectoryEntry group = new DirectoryEntry(groupPath); DirectoryEntry group = new DirectoryEntry(groupPath);
group.Invoke("Add", obj.Path); group.Invoke("Add", obj.Path);
group.CommitChanges();
} }
public static void RemoveObjectFromGroup(string obejctPath, string groupPath) public static void RemoveObjectFromGroup(string obejctPath, string groupPath)
@ -407,6 +409,8 @@ namespace WebsitePanel.Providers.HostedSolution
DirectoryEntry group = new DirectoryEntry(groupPath); DirectoryEntry group = new DirectoryEntry(groupPath);
group.Invoke("Remove", obj.Path); group.Invoke("Remove", obj.Path);
group.CommitChanges();
} }
public static bool AdObjectExists(string path) public static bool AdObjectExists(string path)

View file

@ -4016,7 +4016,25 @@ namespace WebsitePanel.Providers.HostedSolution
id = GetPSObjectIdentity(obj); id = GetPSObjectIdentity(obj);
account = GetExchangeAccount(runSpace, id); account = GetExchangeAccount(runSpace, id);
if (account != null) if (account != null)
{
list.Add(account); 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"); ExchangeLog.LogEnd("GetGroupMembers");
return list.ToArray(); return list.ToArray();

View file

@ -3771,7 +3771,25 @@ namespace WebsitePanel.Providers.HostedSolution
id = GetPSObjectIdentity(obj); id = GetPSObjectIdentity(obj);
account = GetExchangeAccount(runSpace, id); account = GetExchangeAccount(runSpace, id);
if (account != null) if (account != null)
{
list.Add(account); 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"); ExchangeLog.LogEnd("GetGroupMembers");
return list.ToArray(); return list.ToArray();

View file

@ -1015,12 +1015,18 @@ namespace WebsitePanel.Providers.HostedSolution
ActiveDirectoryUtils.SetADObjectProperty(entry, ADAttributes.Notes, notes); 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); 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); ActiveDirectoryUtils.RemoveObjectFromGroup(groupPath, path);
} }
@ -1030,8 +1036,6 @@ namespace WebsitePanel.Providers.HostedSolution
string objPath = GetObjectPath(organizationId, obj); string objPath = GetObjectPath(organizationId, obj);
ActiveDirectoryUtils.AddObjectToGroup(objPath, path); ActiveDirectoryUtils.AddObjectToGroup(objPath, path);
} }
entry.CommitChanges();
} }
public void AddObjectToSecurityGroup(string organizationId, string accountName, string groupName) public void AddObjectToSecurityGroup(string organizationId, string accountName, string groupName)

View file

@ -90,7 +90,7 @@ namespace WebsitePanel.Portal.HostedSolution
// get settings // get settings
OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); 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.Room
|| user.AccountType == ExchangeAccountType.Equipment); || user.AccountType == ExchangeAccountType.Equipment);