Fixed: When deleting an exchange user the operations failed with "Cannot delete

object when there are leaf objects

Ensure activesync devices are removed before deleting or disabling a mailbox
This commit is contained in:
robvde 2012-08-10 11:28:02 +04:00
parent 12d0e687f1
commit 0ecd34363a
2 changed files with 54 additions and 0 deletions

View file

@ -487,10 +487,13 @@ namespace WebsitePanel.Providers.HostedSolution
string addressbookPolicy = ObjToString(GetPSObjectProperty(result[0], "AddressBookPolicy"));
RemoveDevicesInternal(runSpace, id);
cmd = new Command("Disable-Mailbox");
cmd.Parameters.Add("Identity", id);
cmd.Parameters.Add("Confirm", false);
ExecuteShellCommand(runSpace, cmd);
if (addressbookPolicy == (upn + " AP"))
{
@ -552,6 +555,8 @@ namespace WebsitePanel.Providers.HostedSolution
string upn = ObjToString(GetPSObjectProperty(result[0], "UserPrincipalName"));
string addressbookPolicy = ObjToString(GetPSObjectProperty(result[0], "AddressBookPolicy"));
RemoveDevicesInternal(runSpace, accountName);
RemoveMailbox(runSpace, accountName);
if (addressbookPolicy == (upn + " AP"))