protected override void PrepareUserObject(ADUser user)
 {
     TaskLogger.LogEnter();
     base.PrepareUserObject(user);
     if (this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty)
     {
         user.EmailAddressPolicyEnabled = false;
         SmtpProxyAddress item = new SmtpProxyAddress(this.WindowsLiveID.SmtpAddress.ToString(), false);
         if (!user.EmailAddresses.Contains(item))
         {
             user.EmailAddresses.Add(item);
         }
     }
     if (user.ExchangeGuid == SoftDeletedTaskHelper.PredefinedExchangeGuid)
     {
         user.ExchangeGuid = user.PreviousExchangeGuid;
         if (!RecipientTaskHelper.IsExchangeGuidOrArchiveGuidUnique(user, ADMailboxRecipientSchema.ExchangeGuid, user.ExchangeGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client))
         {
             user.ExchangeGuid = Guid.Empty;
         }
         user.PreviousExchangeGuid = Guid.Empty;
     }
     SoftDeletedTaskHelper.UpdateShadowWhenSoftDeletedProperty((IRecipientSession)base.DataSession, this.ConfigurationSession, base.CurrentOrganizationId, this.DataObject);
     this.DataObject.RecipientSoftDeletedStatus = 0;
     this.DataObject.WhenSoftDeleted            = null;
     this.DataObject.InternalOnly = false;
     TaskLogger.LogExit();
 }
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.CreateSession();
            ADObjectId        searchRoot       = recipientSession.SearchRoot;

            if (this.SoftDeletedMailbox.IsPresent && base.CurrentOrganizationId != null && base.CurrentOrganizationId.OrganizationalUnit != null)
            {
                searchRoot = new ADObjectId("OU=Soft Deleted Objects," + base.CurrentOrganizationId.OrganizationalUnit.DistinguishedName);
            }
            if (base.ParameterSetName == "DatabaseSet" || base.ParameterSetName == "ServerSet" || base.ParameterSetName == "MailboxPlanSet" || this.SoftDeletedMailbox.IsPresent || this.IncludeSoftDeletedMailbox.IsPresent)
            {
                if (this.SoftDeletedMailbox.IsPresent || this.IncludeSoftDeletedMailbox.IsPresent)
                {
                    recipientSession.SessionSettings.IncludeSoftDeletedObjects = true;
                }
                IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(recipientSession.DomainController, searchRoot, recipientSession.Lcid, recipientSession.ReadOnly, recipientSession.ConsistencyMode, recipientSession.NetworkCredential, recipientSession.SessionSettings, ConfigScopes.TenantSubTree, 417, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\GetMailbox.cs");
                tenantOrRootOrgRecipientSession.EnforceDefaultScope  = recipientSession.EnforceDefaultScope;
                tenantOrRootOrgRecipientSession.UseGlobalCatalog     = recipientSession.UseGlobalCatalog;
                tenantOrRootOrgRecipientSession.LinkResolutionServer = recipientSession.LinkResolutionServer;
                recipientSession = tenantOrRootOrgRecipientSession;
            }
            if (this.IncludeInactiveMailbox.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.CreateTenantOrRootOrgRecipientSessionIncludeInactiveMailbox(recipientSession, base.CurrentOrganizationId);
            }
            else if (this.InactiveMailboxOnly.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.CreateTenantOrRootOrgRecipientSessionInactiveMailboxOnly(recipientSession, base.CurrentOrganizationId);
            }
            return(recipientSession);
        }
        protected override void InternalStateReset()
        {
            base.InternalStateReset();
            SmtpAddress windowsLiveID = this.DataObject.WindowsLiveID;
            NetID       netID         = this.DataObject.NetID;
            string      name          = this.DataObject.Name;
            string      displayName   = this.DataObject.DisplayName;

            this.DataObject = SoftDeletedTaskHelper.GetSoftDeletedADUser(base.CurrentOrganizationId, this.SoftDeletedObject, new Task.ErrorLoggerDelegate(base.WriteError));
            if (this.DataObject.WindowsLiveID != windowsLiveID)
            {
                this.DataObject.EmailAddressPolicyEnabled = false;
                this.DataObject.WindowsLiveID             = windowsLiveID;
                this.DataObject.UserPrincipalName         = windowsLiveID.ToString();
                this.DataObject.PrimarySmtpAddress        = windowsLiveID;
            }
            if (this.DataObject.NetID != netID)
            {
                this.DataObject.NetID = netID;
            }
            if (!string.IsNullOrEmpty(name))
            {
                this.DataObject.Name = name;
            }
            this.DataObject.Name = SoftDeletedTaskHelper.GetUniqueNameForRecovery((IRecipientSession)base.DataSession, this.DataObject.Name, this.DataObject.Id);
            if (!string.IsNullOrEmpty(displayName))
            {
                this.DataObject.DisplayName = displayName;
            }
        }
        protected override void InternalStateReset()
        {
            base.InternalStateReset();
            string name        = this.DataObject.Name;
            string displayName = this.DataObject.DisplayName;

            this.DataObject = SoftDeletedTaskHelper.GetSoftDeletedADUser(base.CurrentOrganizationId, this.SoftDeletedObject, new Task.ErrorLoggerDelegate(base.WriteError));
            this.previousExchangeVersion = this.DataObject.ExchangeVersion;
            this.DataObject.SetExchangeVersion(ADRecipientSchema.WhenSoftDeleted.VersionAdded);
            if (this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty && this.WindowsLiveID.SmtpAddress != this.DataObject.WindowsLiveID)
            {
                this.DataObject.EmailAddressPolicyEnabled = false;
                this.DataObject.WindowsLiveID             = this.WindowsLiveID.SmtpAddress;
                this.DataObject.UserPrincipalName         = this.WindowsLiveID.SmtpAddress.ToString();
                this.DataObject.PrimarySmtpAddress        = this.WindowsLiveID.SmtpAddress;
            }
            if (!string.IsNullOrEmpty(name))
            {
                this.DataObject.Name = name;
            }
            this.DataObject.Name = SoftDeletedTaskHelper.GetUniqueNameForRecovery((IRecipientSession)base.DataSession, this.DataObject.Name, this.DataObject.Id);
            if (!string.IsNullOrEmpty(displayName))
            {
                this.DataObject.DisplayName = displayName;
            }
        }
 private void RemoveMailUser()
 {
     if (this.mailUser == null)
     {
         this.WriteWarning(Strings.WarningJournalArchiveMailboxHasNoMailUser);
         return;
     }
     if (DisableJournalArchiving.ShouldSoftDeleteUser(this.mailUser))
     {
         SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, this.mailUser, false);
         SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(this.mailUser);
         this.mailUser.JournalArchiveAddress = SmtpAddress.NullReversePath;
         base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.mailUser.Identity, base.DataSession, typeof(ADUser)));
         try
         {
             try
             {
                 RecipientTaskHelper.CreateSoftDeletedObjectsContainerIfNecessary(this.mailUser.Id.Parent, base.DomainController);
                 base.DataSession.Save(this.mailUser);
             }
             catch (DataSourceTransientException exception)
             {
                 base.WriteError(exception, ExchangeErrorCategory.ServerTransient, null);
             }
             return;
         }
         finally
         {
             base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession));
         }
     }
     base.WriteError(new RecipientTaskException(Strings.ErrorDisableJournalArchiveMailuserNotSoftDeleted), ExchangeErrorCategory.Client, this.mailUser.Identity);
 }
Example #6
0
        public static IRecipientSession CreateTenantOrRootOrgRecipientSessionInactiveMailboxOnly(IRecipientSession dataProvider, OrganizationId orgId)
        {
            ADObjectId rootId = dataProvider.SearchRoot;

            if (orgId != null && orgId.OrganizationalUnit != null)
            {
                rootId = new ADObjectId("OU=Soft Deleted Objects," + orgId.OrganizationalUnit.DistinguishedName);
            }
            return(SoftDeletedTaskHelper.CreateIncludeInactiveMailboxTenantOrRootOrgRecipientSession(dataProvider, rootId));
        }
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.CreateSession();

            if (this.SoftDeletedMailUser.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(recipientSession, null);
            }
            return(recipientSession);
        }
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.CreateSession();

            if (this.Disconnect.IsPresent || base.ForReconciliation.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(recipientSession, null);
            }
            return(recipientSession);
        }
        protected override IEnumerable <ADRawEntry> GetPagedData()
        {
            if (this.Cookie == null)
            {
                DeletedRecipient item = new DeletedRecipient();
                return(new List <ADRawEntry>
                {
                    item
                });
            }
            PropertyDefinition[] properties = new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADObjectSchema.Name,
                ADObjectSchema.DistinguishedName,
                ADObjectSchema.Guid,
                ADObjectSchema.OrganizationalUnitRoot,
                ADObjectSchema.ObjectClass,
                ADObjectSchema.WhenChanged,
                ADObjectSchema.WhenChangedUTC,
                ADObjectSchema.WhenCreated,
                ADObjectSchema.WhenCreatedUTC
            };
            if (this.requireTwoQueries)
            {
                IRecipientSession sessionForSoftDeletedObjects = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(base.CurrentOrganizationId, this.DomainController);
                ADObjectId        childId     = base.CurrentOrganizationId.OrganizationalUnit.GetChildId("OU", "Soft Deleted Objects");
                QueryFilter       queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.IsSoftDeletedByRemove, true);
                queryFilter = new AndFilter(new QueryFilter[]
                {
                    queryFilter,
                    SyncTaskHelper.GetDeltaFilter(this.inputCookie)
                });
                this.reader2        = sessionForSoftDeletedObjects.FindPagedADRawEntry(childId, QueryScope.OneLevel, queryFilter, null, this.PageSize, properties);
                this.reader2.Cookie = this.inputCookie.PageCookie2;
                base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(sessionForSoftDeletedObjects, typeof(ADRawEntry), queryFilter, null, false));
            }
            IRecipientSession recipientSession        = (IRecipientSession)base.DataSession;
            ADObjectId        deletedObjectsContainer = ADSession.GetDeletedObjectsContainer(recipientSession.GetDomainNamingContext());
            QueryFilter       internalFilter          = this.InternalFilter;

            recipientSession.SessionSettings.SkipCheckVirtualIndex = true;
            ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(deletedObjectsContainer, QueryScope.OneLevel, internalFilter, null, this.PageSize, properties);

            adpagedReader.IncludeDeletedObjects = true;
            adpagedReader.Cookie = this.inputCookie.PageCookie;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADRawEntry), this.InternalFilter, null, false));
            return(adpagedReader);
        }
Example #10
0
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.CreateSession();
            ADObjectId        rootId           = recipientSession.SearchRoot;

            if (this.SoftDeletedMailUser.IsPresent && base.CurrentOrganizationId != null && base.CurrentOrganizationId.OrganizationalUnit != null)
            {
                rootId = new ADObjectId("OU=Soft Deleted Objects," + base.CurrentOrganizationId.OrganizationalUnit.DistinguishedName);
            }
            if (this.SoftDeletedMailUser.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(recipientSession, rootId);
            }
            return(recipientSession);
        }
Example #11
0
 protected override void InternalProcessRecord()
 {
     if (Globals.IsMicrosoftHostedOnly)
     {
         ADUser dataObject = base.DataObject;
         if (this.ShouldSoftDeleteObject())
         {
             SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, this.ForReconciliation);
         }
         else
         {
             dataObject.propertyBag.SetField(ADRecipientSchema.RecipientSoftDeletedStatus, 0);
         }
     }
     base.InternalProcessRecord();
 }
Example #12
0
 protected override void InternalProcessRecord()
 {
     if (Globals.IsMicrosoftHostedOnly)
     {
         ADUser dataObject = base.DataObject;
         if (this.ShouldSoftDeleteObject())
         {
             SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, this.ForReconciliation);
             SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(dataObject);
         }
         else
         {
             dataObject.RecipientSoftDeletedStatus = 0;
         }
     }
     base.InternalProcessRecord();
 }
Example #13
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            ADUser aduser = (ADUser)base.PrepareDataObject();

            if (aduser.IsChanged(MailUserSchema.WindowsLiveID))
            {
                SmtpAddress value = (SmtpAddress)aduser.GetOriginalObject()[MailUserSchema.WindowsLiveID];
                if (value != SmtpAddress.Empty && !aduser.EmailAddresses.Contains(ProxyAddress.Parse("smtp", value.ToString())))
                {
                    aduser.EmailAddresses.Add(ProxyAddress.Parse("smtp", value.ToString()));
                }
            }
            if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled)
            {
                if (aduser.IsChanged(ADRecipientSchema.ExternalEmailAddress))
                {
                    MailUserTaskHelper.ValidateExternalEmailAddress(aduser, this.ConfigurationSession, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache);
                }
                if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.WindowsLiveID.Enabled)
                {
                    if (aduser.WindowsLiveID != SmtpAddress.Empty && !aduser.WindowsLiveID.Equals(aduser.UserPrincipalName))
                    {
                        aduser.UserPrincipalName = aduser.WindowsLiveID.ToString();
                    }
                }
                else if (!aduser.IsModified(ADUserSchema.UserPrincipalName))
                {
                    aduser.UserPrincipalName = aduser.PrimarySmtpAddress.ToString();
                }
                if (this.DataObject.IsSoftDeleted && this.DataObject.IsModified(MailUserSchema.ExchangeGuid))
                {
                    SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(this.DataObject);
                }
                if ((aduser.IsChanged(ADUserSchema.LitigationHoldEnabled) && aduser.LitigationHoldEnabled) || (aduser.IsChanged(ADRecipientSchema.InPlaceHoldsRaw) && aduser.IsInLitigationHoldOrInplaceHold) || (aduser.IsChanged(ADUserSchema.ElcMailboxFlags) && aduser.LitigationHoldEnabled))
                {
                    RecoverableItemsQuotaHelper.IncreaseRecoverableItemsQuotaIfNeeded(aduser);
                }
            }
            TaskLogger.LogExit();
            return(aduser);
        }
Example #14
0
        protected override IConfigDataProvider CreateSession()
        {
            IRecipientSession recipientSession = (IRecipientSession)base.CreateSession();
            ADObjectId        rootId           = recipientSession.SearchRoot;

            if (this.SoftDeletedMailUser.IsPresent && base.CurrentOrganizationId != null && base.CurrentOrganizationId.OrganizationalUnit != null)
            {
                rootId = new ADObjectId("OU=Soft Deleted Objects," + base.CurrentOrganizationId.OrganizationalUnit.DistinguishedName);
            }
            if (this.SoftDeletedMailUser.IsPresent)
            {
                recipientSession = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(recipientSession, rootId);
            }
            if (base.ParameterSetName == "CookieSet")
            {
                recipientSession.UseGlobalCatalog = true;
                this.inputCookie = SyncTaskHelper.ResolveSyncCookie(this.Cookie, recipientSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError));
            }
            return(recipientSession);
        }
Example #15
0
        internal static ADUser GetSoftDeletedADUser(OrganizationId organizationId, RecipientIdParameter identity, Task.ErrorLoggerDelegate errorLogger)
        {
            IRecipientSession    sessionForSoftDeletedObjects = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(organizationId, null);
            IEnumerable <ADUser> enumerable = identity.GetObjects <ADUser>(organizationId.OrganizationalUnit, sessionForSoftDeletedObjects) ?? new List <ADUser>();
            ADUser result;

            using (IEnumerator <ADUser> enumerator = enumerable.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    errorLogger(new RecipientTaskException(Strings.ErrorMailboxNotFound(identity.ToString())), ExchangeErrorCategory.Client, null);
                }
                result = enumerator.Current;
                if (enumerator.MoveNext())
                {
                    errorLogger(new RecipientTaskException(Strings.ErrorMailboxNotUnique(identity.ToString())), ExchangeErrorCategory.Client, null);
                }
            }
            return(result);
        }
 protected override void PrepareRecipientObject(ADUser user)
 {
     TaskLogger.LogEnter();
     base.PrepareRecipientObject(user);
     if (this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty)
     {
         MailboxTaskHelper.IsLiveIdExists((IRecipientSession)base.DataSession, user.WindowsLiveID, user.NetID, new Task.ErrorLoggerDelegate(base.WriteError));
         user.UserPrincipalName = user.WindowsLiveID.ToString();
     }
     if (!user.IsModified(ADRecipientSchema.DisplayName))
     {
         user.DisplayName = user.Name;
     }
     SoftDeletedTaskHelper.UpdateShadowWhenSoftDeletedProperty((IRecipientSession)base.DataSession, this.ConfigurationSession, base.CurrentOrganizationId, this.DataObject);
     this.DataObject.RecipientSoftDeletedStatus = 0;
     this.DataObject.WhenSoftDeleted            = null;
     this.DataObject.InternalOnly = false;
     this.DataObject.propertyBag.MarkAsChanged(ADRecipientSchema.RecipientSoftDeletedStatus);
     this.DataObject.propertyBag.MarkAsChanged(ADRecipientSchema.WhenSoftDeleted);
     this.DataObject.propertyBag.MarkAsChanged(ADRecipientSchema.TransportSettingFlags);
     TaskLogger.LogExit();
 }
        protected override bool ShouldSoftDeleteObject()
        {
            ADRecipient dataObject = base.DataObject;

            return(dataObject != null && !(dataObject.OrganizationId == null) && dataObject.OrganizationId.ConfigurationUnit != null && SoftDeletedTaskHelper.IsSoftDeleteSupportedRecipientTypeDetail(dataObject.RecipientTypeDetails) && !base.Disconnect && !base.Permanent && VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.SoftDeleteObject.Enabled);
        }
        private bool IsToInactiveMailbox()
        {
            ADUser dataObject = base.DataObject;

            return(this.ShouldSoftDeleteObject() && SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId) && dataObject.IsInLitigationHoldOrInplaceHold && !this.IgnoreLegalHold);
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            ADObjectId adobjectId = null;
            Guid       guid       = Guid.Empty;
            string     text       = string.Empty;
            bool       flag       = this.ShouldSoftDeleteObject();
            ADUser     dataObject = base.DataObject;

            if (Globals.IsMicrosoftHostedOnly)
            {
                if (flag)
                {
                    bool flag2 = SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId);
                    bool includeInGarbageCollection = (!flag2 || base.ForReconciliation) && !this.isToInactiveMailbox;
                    SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, dataObject, includeInGarbageCollection, this.isToInactiveMailbox);
                }
                else
                {
                    if (this.isDisconnectInactiveMailbox)
                    {
                        SoftDeletedTaskHelper.UpdateMailboxForDisconnectInactiveMailbox(dataObject);
                        base.DataSession.Save(dataObject);
                        TaskLogger.LogExit();
                        this.LogRemoveMailboxDetails(dataObject);
                        return;
                    }
                    dataObject.RecipientSoftDeletedStatus = 0;
                }
            }
            if (this.Identity != null)
            {
                adobjectId = base.DataObject.Database;
                guid       = base.DataObject.ExchangeGuid;
                if (adobjectId == null)
                {
                    TaskLogger.Trace("The homeMDB is empty for this user, we just try to remove the user AD object", new object[0]);
                }
                else if (guid == Guid.Empty)
                {
                    TaskLogger.Trace("The ExchangeGuid is empty for this user, we just try to remove the user AD object", new object[0]);
                }
                else if (base.DataObject.RecipientTypeDetails == RecipientTypeDetails.MailboxPlan)
                {
                    TaskLogger.Trace("This user is MailboxPlan, we just try to remove the user AD object", new object[0]);
                }
                else if (!flag)
                {
                    try
                    {
                        DatabaseLocationInfo databaseLocationInfo = null;
                        try
                        {
                            databaseLocationInfo = ActiveManager.GetActiveManagerInstance().GetServerForDatabase(adobjectId.ObjectGuid);
                        }
                        catch (ObjectNotFoundException exception)
                        {
                            base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null);
                        }
                        if (databaseLocationInfo == null)
                        {
                            if (this.Permanent)
                            {
                                base.WriteError(new TaskInvalidOperationException(Strings.ErrorGetServerNameFromMailbox(base.DataObject.Identity.ToString())), ExchangeErrorCategory.ServerOperation, base.DataObject);
                            }
                            else
                            {
                                TaskLogger.Trace("cannot get the server name for mailbox {0}", new object[]
                                {
                                    base.DataObject.Identity
                                });
                            }
                        }
                        else
                        {
                            text = databaseLocationInfo.ServerFqdn;
                            base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(text));
                            this.mapiSession = new MapiAdministrationSession(databaseLocationInfo.ServerLegacyDN, Fqdn.Parse(text));
                        }
                    }
                    catch (MapiPermanentException ex)
                    {
                        if (this.Permanent)
                        {
                            base.WriteError(ex, ExchangeErrorCategory.ServerOperation, this.Identity);
                        }
                        else
                        {
                            TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                            {
                                ex
                            });
                        }
                    }
                    catch (MapiRetryableException ex2)
                    {
                        if (this.Permanent)
                        {
                            base.WriteError(ex2, ExchangeErrorCategory.ServerTransient, this.Identity);
                        }
                        else
                        {
                            TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                            {
                                ex2
                            });
                        }
                    }
                    try
                    {
                        if (dataObject != null && base.ForReconciliation)
                        {
                            base.DataObject.ExternalDirectoryObjectId = string.Empty;
                        }
                        base.DataObject.PreviousDatabase = base.DataObject.Database;
                        base.DataSession.Save(base.DataObject);
                    }
                    catch (DataSourceTransientException exception2)
                    {
                        base.WriteError(exception2, ExchangeErrorCategory.ServerTransient, null);
                    }
                    catch (InvalidObjectOperationException)
                    {
                    }
                    catch (DataValidationException)
                    {
                    }
                    catch (ADOperationException)
                    {
                    }
                }
                base.InternalProcessRecord();
                this.LogRemoveMailboxDetails(dataObject);
            }
            if (this.StoreMailboxIdentity != null || this.Permanent)
            {
                if (this.Permanent)
                {
                    if (!(guid != Guid.Empty) || adobjectId == null)
                    {
                        goto IL_5A0;
                    }
                    try
                    {
                        base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(guid.ToString(), adobjectId.ToString()));
                        this.mapiSession.DeleteMailbox(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(adobjectId), guid));
                        goto IL_5A0;
                    }
                    catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex3)
                    {
                        TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                        {
                            ex3
                        });
                        base.WriteVerbose(ex3.LocalizedString);
                        goto IL_5A0;
                    }
                    catch (DataSourceOperationException exception3)
                    {
                        base.WriteError(exception3, ExchangeErrorCategory.ServerOperation, base.DataObject);
                        goto IL_5A0;
                    }
                }
                try
                {
                    base.WriteVerbose(Strings.VerboseDeleteMailboxInStore(this.mailboxStatistics.MailboxGuid.ToString(), this.mailboxStatistics.Database.ToString()));
                    ((IConfigDataProvider)this.mapiSession).Delete(this.mailboxStatistics);
                    goto IL_5A0;
                }
                catch (DataSourceOperationException exception4)
                {
                    base.WriteError(exception4, ExchangeErrorCategory.ServerOperation, (this.Identity == null) ? this.StoreMailboxIdentity : this.Identity);
                    goto IL_5A0;
                }
            }
            if (this.mapiSession != null)
            {
                try
                {
                    TIdentity identity = this.Identity;
                    base.WriteVerbose(Strings.VerboseSyncMailboxWithDS(identity.ToString(), base.DataObject.Database.ToString(), text));
                    bool flag3 = true;
                    if (base.DataObject.Database == null || Guid.Empty == base.DataObject.Database.ObjectGuid)
                    {
                        flag3 = false;
                        TaskLogger.Trace("Cannot get the database for mailbox '{0}'", new object[]
                        {
                            base.DataObject.Identity
                        });
                    }
                    if (Guid.Empty == base.DataObject.ExchangeGuid)
                    {
                        flag3 = false;
                        TaskLogger.Trace("Cannot get the mailbox guid for mailbox '{0}'", new object[]
                        {
                            base.DataObject.Identity
                        });
                    }
                    if (flag3)
                    {
                        this.mapiSession.SyncMailboxWithDS(new MailboxId(MapiTaskHelper.ConvertDatabaseADObjectIdToDatabaseId(base.DataObject.Database), base.DataObject.ExchangeGuid));
                    }
                }
                catch (Microsoft.Exchange.Data.Mapi.Common.MailboxNotFoundException ex4)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex4
                    });
                    base.WriteVerbose(ex4.LocalizedString);
                }
                catch (DataSourceTransientException ex5)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex5
                    });
                    this.WriteWarning(ex5.LocalizedString);
                }
                catch (DataSourceOperationException ex6)
                {
                    TaskLogger.Trace("Swallowing exception {0} from mapi.net", new object[]
                    {
                        ex6
                    });
                    this.WriteWarning(ex6.LocalizedString);
                }
            }
IL_5A0:
            if (!flag && this.mailboxStatistics != null)
            {
                this.mailboxStatistics.Dispose();
                this.mailboxStatistics = null;
            }
            this.DisposeMapiSession();
            TaskLogger.LogExit();
        }
Example #20
0
        protected override bool ShouldSoftDeleteObject()
        {
            ADRecipient dataObject = base.DataObject;

            return(dataObject != null && !(dataObject.OrganizationId == null) && dataObject.OrganizationId.ConfigurationUnit != null && !this.Permanent && Globals.IsMicrosoftHostedOnly && SoftDeletedTaskHelper.MSOSyncEnabled(this.ConfigurationSession, dataObject.OrganizationId));
        }
Example #21
0
        protected override bool ShouldSoftDeleteObject()
        {
            ADRecipient dataObject = base.DataObject;

            return(dataObject != null && !(dataObject.OrganizationId == null) && dataObject.OrganizationId.ConfigurationUnit != null && !base.Disconnect && !base.Permanent && Globals.IsMicrosoftHostedOnly && SoftDeletedTaskHelper.IsSoftDeleteSupportedRecipientTypeDetail(dataObject.RecipientTypeDetails));
        }
Example #22
0
 internal static void UpdateRecipientForSoftDelete(IRecipientSession session, ADUser recipient, bool includeInGarbageCollection)
 {
     SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(session, recipient, includeInGarbageCollection, false);
 }
 private static bool ShouldSoftDeleteUser(ADUser user)
 {
     return(user != null && !(user.OrganizationId == null) && user.OrganizationId.ConfigurationUnit != null && Globals.IsMicrosoftHostedOnly && SoftDeletedTaskHelper.IsSoftDeleteSupportedRecipientTypeDetail(user.RecipientTypeDetails));
 }
Example #24
0
 public static IRecipientSession CreateTenantOrRootOrgRecipientSessionIncludeInactiveMailbox(IRecipientSession dataProvider, OrganizationId orgId)
 {
     return(SoftDeletedTaskHelper.CreateIncludeInactiveMailboxTenantOrRootOrgRecipientSession(dataProvider, null));
 }