Merge
This commit is contained in:
commit
b52712c9a1
2 changed files with 47 additions and 18 deletions
|
@ -589,6 +589,15 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
|
|
||||||
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
|
ExchangeServer exchange = GetExchangeServer(exchangeServiceId, org.ServiceId);
|
||||||
|
|
||||||
|
// delete public folders
|
||||||
|
List<ExchangeAccount> folders = GetAccounts(itemId, ExchangeAccountType.PublicFolder);
|
||||||
|
folders.Sort(delegate(ExchangeAccount f1, ExchangeAccount f2) { return f2.AccountId.CompareTo(f1.AccountId); });
|
||||||
|
|
||||||
|
foreach (ExchangeAccount folder in folders)
|
||||||
|
DeletePublicFolder(itemId, folder.AccountId);
|
||||||
|
|
||||||
|
exchange.DeletePublicFolder(org.OrganizationId, "\\" + org.OrganizationId);
|
||||||
|
|
||||||
bool successful = exchange.DeleteOrganization(
|
bool successful = exchange.DeleteOrganization(
|
||||||
org.OrganizationId,
|
org.OrganizationId,
|
||||||
org.DistinguishedName,
|
org.DistinguishedName,
|
||||||
|
@ -600,19 +609,6 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
org.AddressBookPolicy,
|
org.AddressBookPolicy,
|
||||||
acceptedDomains.ToArray());
|
acceptedDomains.ToArray());
|
||||||
|
|
||||||
// delete public folders
|
|
||||||
if (successful)
|
|
||||||
{
|
|
||||||
List<ExchangeAccount> folders = GetAccounts(itemId, ExchangeAccountType.PublicFolder);
|
|
||||||
folders.Sort(delegate(ExchangeAccount f1, ExchangeAccount f2) { return f2.AccountId.CompareTo(f1.AccountId);});
|
|
||||||
|
|
||||||
foreach(ExchangeAccount folder in folders)
|
|
||||||
DeletePublicFolder(itemId, folder.AccountId);
|
|
||||||
|
|
||||||
exchange.DeletePublicFolder(org.OrganizationId, "\\" + org.OrganizationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return successful ? 0 : BusinessErrorCodes.ERROR_EXCHANGE_DELETE_SOME_PROBLEMS;
|
return successful ? 0 : BusinessErrorCodes.ERROR_EXCHANGE_DELETE_SOME_PROBLEMS;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -1004,7 +1004,10 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!DeleteOrganizationMailboxes(runSpace, ou))
|
if (!DeleteOrganizationMailboxes(runSpace, ou, false))
|
||||||
|
ret = false;
|
||||||
|
|
||||||
|
if (!DeleteOrganizationMailboxes(runSpace, ou, true))
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
||||||
if (!DeleteOrganizationContacts(runSpace, ou))
|
if (!DeleteOrganizationContacts(runSpace, ou))
|
||||||
|
@ -1159,13 +1162,15 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool DeleteOrganizationMailboxes(Runspace runSpace, string ou)
|
internal bool DeleteOrganizationMailboxes(Runspace runSpace, string ou, bool publicFolder)
|
||||||
{
|
{
|
||||||
ExchangeLog.LogStart("DeleteOrganizationMailboxes");
|
ExchangeLog.LogStart("DeleteOrganizationMailboxes");
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
Command cmd = new Command("Get-Mailbox");
|
Command cmd = new Command("Get-Mailbox");
|
||||||
cmd.Parameters.Add("OrganizationalUnit", ou);
|
cmd.Parameters.Add("OrganizationalUnit", ou);
|
||||||
|
if (publicFolder) cmd.Parameters.Add("PublicFolder");
|
||||||
|
|
||||||
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd);
|
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd);
|
||||||
if (result != null && result.Count > 0)
|
if (result != null && result.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -1177,7 +1182,7 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
id = ObjToString(GetPSObjectProperty(obj, "Identity"));
|
id = ObjToString(GetPSObjectProperty(obj, "Identity"));
|
||||||
RemoveDevicesInternal(runSpace, id);
|
RemoveDevicesInternal(runSpace, id);
|
||||||
|
|
||||||
RemoveMailbox(runSpace, id, false);
|
RemoveMailbox(runSpace, id, publicFolder);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -3193,6 +3198,15 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Contacts
|
#region Contacts
|
||||||
|
|
||||||
|
private bool CheckEmailExist(Runspace runSpace, string email)
|
||||||
|
{
|
||||||
|
Command cmd = new Command("Get-Recipient");
|
||||||
|
cmd.Parameters.Add("Identity", email);
|
||||||
|
Collection<PSObject> result = ExecuteShellCommand(runSpace, cmd);
|
||||||
|
return result.Count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
private void CreateContactInternal(
|
private void CreateContactInternal(
|
||||||
string organizationId,
|
string organizationId,
|
||||||
string organizationDistinguishedName,
|
string organizationDistinguishedName,
|
||||||
|
@ -3214,9 +3228,29 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
{
|
{
|
||||||
runSpace = OpenRunspace();
|
runSpace = OpenRunspace();
|
||||||
|
|
||||||
|
//
|
||||||
|
string tempEmailUser = Guid.NewGuid().ToString("N");
|
||||||
|
string[] parts = contactEmail.Split('@');
|
||||||
|
if (parts.Length==2)
|
||||||
|
{
|
||||||
|
if (CheckEmailExist(runSpace, parts[0] + "@" + defaultOrganizationDomain))
|
||||||
|
{
|
||||||
|
for(int num=1;num<100;num++)
|
||||||
|
{
|
||||||
|
string testEmailUser = parts[0] + num.ToString();
|
||||||
|
if (!CheckEmailExist(runSpace, testEmailUser + "@" + defaultOrganizationDomain))
|
||||||
|
{
|
||||||
|
tempEmailUser = testEmailUser;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tempEmailUser = parts[0];
|
||||||
|
}
|
||||||
|
|
||||||
string ouName = ConvertADPathToCanonicalName(organizationDistinguishedName);
|
string ouName = ConvertADPathToCanonicalName(organizationDistinguishedName);
|
||||||
string tempEmail = string.Format("{0}@{1}", Guid.NewGuid().ToString("N"), defaultOrganizationDomain);
|
string tempEmail = string.Format("{0}@{1}", tempEmailUser, defaultOrganizationDomain);
|
||||||
//create contact
|
//create contact
|
||||||
Command cmd = new Command("New-MailContact");
|
Command cmd = new Command("New-MailContact");
|
||||||
cmd.Parameters.Add("Name", contactAccountName);
|
cmd.Parameters.Add("Name", contactAccountName);
|
||||||
|
@ -4575,7 +4609,6 @@ namespace WebsitePanel.Providers.HostedSolution
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
||||||
CloseRunspace(runSpace);
|
CloseRunspace(runSpace);
|
||||||
}
|
}
|
||||||
ExchangeLog.LogEnd("DeletePublicFolderInternal");
|
ExchangeLog.LogEnd("DeletePublicFolderInternal");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue