Esempio n. 1
0
        internal static void ValidateOverrideDuration(EnhancedTimeSpan?duration)
        {
            EnhancedTimeSpan zero = EnhancedTimeSpan.Zero;
            EnhancedTimeSpan t    = EnhancedTimeSpan.FromDays(365.0);

            if ((duration != null && duration.Value <= zero) || (duration != null && duration.Value > t))
            {
                throw new InvalidDurationException(zero.ToString(), t.ToString());
            }
        }
Esempio n. 2
0
		protected override void InternalProcessRecord()
		{
			TaskLogger.LogEnter(new object[]
			{
				this.DataObject
			});
			bool flag = false;
			if (false == this.Force && this.Arbitration)
			{
				TIdentity identity = this.Identity;
				if (!base.ShouldContinue(Strings.SetArbitrationMailboxConfirmationMessage(identity.ToString())))
				{
					TaskLogger.LogExit();
					return;
				}
			}
			if (false == this.Force && this.originalForwardingAddress == null && this.DataObject.ForwardingAddress != null && this.DataObject.ForwardingSmtpAddress != null)
			{
				LocalizedString message = (this.originalForwardingSmtpAddress != null) ? Strings.SetMailboxForwardingAddressConfirmationMessage : Strings.SetBothForwardingAddressConfirmationMessage;
				if (!base.ShouldContinue(message))
				{
					TaskLogger.LogExit();
					return;
				}
			}
			if (this.DataObject.IsModified(MailboxSchema.ForwardingSmtpAddress) && this.DataObject.ForwardingSmtpAddress != null && this.DataObject.ForwardingAddress != null && !base.Fields.IsModified(MailboxSchema.ForwardingAddress))
			{
				this.WriteWarning(Strings.ContactAdminForForwardingWarning);
			}
			if (false == this.Force && this.DataObject.IsModified(ADRecipientSchema.AuditLogAgeLimit))
			{
				EnhancedTimeSpan t;
				if (this.DataObject.MailboxAuditLogAgeLimit == EnhancedTimeSpan.Zero)
				{
					TIdentity identity2 = this.Identity;
					if (!base.ShouldContinue(Strings.ConfirmationMessageSetMailboxAuditLogAgeLimitZero(identity2.ToString())))
					{
						TaskLogger.LogExit();
						return;
					}
				}
				else if (this.DataObject.TryGetOriginalValue<EnhancedTimeSpan>(ADRecipientSchema.AuditLogAgeLimit, out t))
				{
					EnhancedTimeSpan mailboxAuditLogAgeLimit = this.DataObject.MailboxAuditLogAgeLimit;
					if (t > mailboxAuditLogAgeLimit)
					{
						TIdentity identity3 = this.Identity;
						if (!base.ShouldContinue(Strings.ConfirmationMessageSetMailboxAuditLogAgeLimitSmaller(identity3.ToString(), mailboxAuditLogAgeLimit.ToString())))
						{
							TaskLogger.LogExit();
							return;
						}
					}
				}
			}
			bool flag2 = false;
			bool flag3 = false;
			MapiMessageStoreSession mapiMessageStoreSession = null;
			try
			{
				if (this.needChangeMailboxSubtype)
				{
					if (this.originalRecipientTypeDetails == RecipientTypeDetails.UserMailbox)
					{
						MailboxTaskHelper.GrantPermissionToLinkedUserAccount(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
						flag2 = true;
						flag3 = true;
					}
					else if (this.targetRecipientTypeDetails == RecipientTypeDetails.UserMailbox)
					{
						MailboxTaskHelper.ClearExternalAssociatedAccountPermission(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
						flag = true;
						flag3 = true;
					}
				}
				else if (this.DataObject.IsChanged(ADRecipientSchema.MasterAccountSid))
				{
					MailboxTaskHelper.GrantPermissionToLinkedUserAccount(this.DataObject, PermissionTaskHelper.GetReadOnlySession(null), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
					flag2 = true;
					flag3 = true;
				}
				base.InternalProcessRecord();
				if (flag3)
				{
					PermissionTaskHelper.SaveMailboxSecurityDescriptor(this.DataObject, SecurityDescriptorConverter.ConvertToActiveDirectorySecurity(this.DataObject.ExchangeSecurityDescriptor), (IRecipientSession)base.DataSession, ref mapiMessageStoreSession, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError));
				}
			}
			finally
			{
				if (mapiMessageStoreSession != null)
				{
					mapiMessageStoreSession.Dispose();
				}
			}
			if (flag2)
			{
				base.WriteVerbose(Strings.VerboseSaveADSecurityDescriptor(this.DataObject.Id.ToString()));
				this.DataObject.SaveSecurityDescriptor(((SecurityDescriptor)this.DataObject[ADObjectSchema.NTSecurityDescriptor]).ToRawSecurityDescriptor());
			}
			bool flag4 = base.Fields.IsModified(ADUserSchema.SharingPolicy);
			if (this.RemoveManagedFolderAndPolicy || flag || flag4)
			{
				ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, false);
				IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, true, ConsistencyMode.IgnoreInvalid, sessionSettings, 4021, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\SetMailbox.cs");
				if (!tenantOrRootOrgRecipientSession.IsReadConnectionAvailable())
				{
					tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, sessionSettings, 4030, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\mailbox\\SetMailbox.cs");
				}
				MailboxSession mailboxSession = this.OpenMailboxSession(tenantOrRootOrgRecipientSession, this.DataObject);
				if (mailboxSession == null)
				{
					base.WriteError(new RecipientTaskException(Strings.LogonFailure), ExchangeErrorCategory.ServerOperation, null);
					return;
				}
				using (mailboxSession)
				{
					if (this.RemoveManagedFolderAndPolicy && !ElcMailboxHelper.RemoveElcInMailbox(mailboxSession))
					{
						this.WriteWarning(Strings.WarningNonemptyManagedFolderNotDeleted);
					}
					if (flag)
					{
						using (CalendarConfigurationDataProvider calendarConfigurationDataProvider = new CalendarConfigurationDataProvider(mailboxSession))
						{
							CalendarConfiguration calendarConfiguration = (CalendarConfiguration)calendarConfigurationDataProvider.Read<CalendarConfiguration>(null);
							calendarConfiguration.AutomateProcessing = CalendarProcessingFlags.None;
							try
							{
								calendarConfigurationDataProvider.Save(calendarConfiguration);
							}
							catch (LocalizedException exception)
							{
								base.WriteError(exception, ExchangeErrorCategory.ServerOperation, null);
							}
						}
					}
					if (flag4)
					{
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedId);
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedHash);
						mailboxSession.Mailbox.Delete(MailboxSchema.LastSharingPolicyAppliedTime);
						mailboxSession.Mailbox.Save();
					}
				}
			}
			if (base.IsSetRandomPassword)
			{
				MailboxTaskHelper.SetMailboxPassword((IRecipientSession)base.DataSession, this.DataObject, null, new Task.ErrorLoggerDelegate(base.WriteError));
			}
			TaskLogger.LogExit();
		}
Esempio n. 3
0
 protected override void InternalValidate()
 {
     if (this.Duration != null)
     {
         EnhancedTimeSpan zero = EnhancedTimeSpan.Zero;
         if (this.Duration.Value <= zero)
         {
             base.WriteError(new ArgumentException(Strings.DurationShouldBeGreaterThanZero(zero.ToString()), "Duration"), ErrorCategory.InvalidData, null);
         }
         EnhancedTimeSpan t = EnhancedTimeSpan.FromDays(365.0);
         if (this.Duration.Value > t)
         {
             base.WriteError(new ArgumentException(Strings.DurationShouldBeLessThan1Year(t.ToString()), "Duration"), ErrorCategory.InvalidData, null);
         }
     }
     base.InternalValidate();
 }
Esempio n. 4
0
 protected override void InternalProcessRecord()
 {
     if (this.DataObject.IsChanged(AdminAuditLogConfigSchema.AdminAuditLogAgeLimit) && !this.Force)
     {
         EnhancedTimeSpan t;
         if (this.DataObject.AdminAuditLogAgeLimit == EnhancedTimeSpan.Zero)
         {
             if (!base.ShouldContinue(Strings.ConfirmationMessageAdminAuditLogAgeLimitZero(base.CurrentOrgContainerId.ToString())))
             {
                 return;
             }
         }
         else if (this.DataObject.TryGetOriginalValue <EnhancedTimeSpan>(AdminAuditLogConfigSchema.AdminAuditLogAgeLimit, out t))
         {
             EnhancedTimeSpan adminAuditLogAgeLimit = this.DataObject.AdminAuditLogAgeLimit;
             if (t > adminAuditLogAgeLimit && !base.ShouldContinue(Strings.ConfirmationMessageAdminAuditLogAgeLimitSmaller(base.CurrentOrgContainerId.ToString(), adminAuditLogAgeLimit.ToString())))
             {
                 return;
             }
         }
     }
     if (this.IsObjectStateChanged())
     {
         this.WriteWarning(Strings.WarningSetAdminAuditLogConfigDelay(SetAdminAuditLogConfig.AuditConfigSettingsDelayTime.TotalMinutes));
     }
     if (AdminAuditLogHelper.ShouldIssueWarning(base.CurrentOrganizationId))
     {
         this.WriteWarning(Strings.WarningSetAdminAuditLogOnPreE15(base.CurrentOrganizationId.ToString()));
     }
     base.InternalProcessRecord();
     ProvisioningLayer.RefreshProvisioningBroker(this);
 }
 // Token: 0x06000644 RID: 1604 RVA: 0x00030114 File Offset: 0x0002E314
 protected override void CollectItemsToExpire()
 {
     AuditFolderStrategy[] array = new AuditFolderStrategy[]
     {
         new MailboxAuditFolderStrategy(base.MailboxDataForTags, AuditExpirationEnforcer.Tracer),
         new AdminAuditFolderStrategy(base.MailboxDataForTags, AuditExpirationEnforcer.Tracer)
     };
     foreach (AuditFolderStrategy auditFolderStrategy in array)
     {
         StoreId folderId = auditFolderStrategy.GetFolderId(base.MailboxDataForTags.MailboxSession);
         if (folderId != null)
         {
             EnhancedTimeSpan auditRecordAgeLimit = auditFolderStrategy.AuditRecordAgeLimit;
             if (auditFolderStrategy is AdminAuditFolderStrategy)
             {
                 using (Folder folder = Folder.Bind(base.MailboxDataForTags.MailboxSession, folderId, new PropertyDefinition[]
                 {
                     FolderSchema.ExtendedSize
                 }))
                 {
                     this.CheckAndLogAdminAuditsWarningQuota(folder);
                 }
                 base.MailboxDataForTags.StatisticsLogEntry.AdminAuditRecordAgeLimit = auditRecordAgeLimit.ToString();
                 base.MailboxDataForTags.StatisticsLogEntry.IsAdminAuditLog          = true;
             }
             else
             {
                 base.MailboxDataForTags.StatisticsLogEntry.MailboxAuditRecordAgeLimit = auditRecordAgeLimit.ToString();
             }
             AuditLogCollection auditLogCollection = new AuditLogCollection(base.MailboxDataForTags.MailboxSession, folderId, AuditExpirationEnforcer.Tracer);
             this.expirationTime = DateTime.MinValue;
             if (ElcGlobals.ExpireDumpsterRightNow)
             {
                 this.expirationTime = DateTime.MaxValue;
             }
             else if (auditRecordAgeLimit != EnhancedTimeSpan.MaxValue)
             {
                 this.expirationTime = base.MailboxDataForTags.UtcNow.Subtract(auditRecordAgeLimit);
             }
             if (this.expirationTime != DateTime.MinValue)
             {
                 List <VersionedId> list = new List <VersionedId>();
                 int num = 0;
                 foreach (AuditLog auditLog in auditLogCollection.GetExpiringAuditLogs(this.expirationTime))
                 {
                     foreach (ItemData itemData in auditLog.FindAuditRecords <ItemData>(this))
                     {
                         base.TagExpirationExecutor.AddToDoomedHardDeleteList(itemData, false);
                         this.itemsExpired++;
                         num++;
                         if (num % 100 == 0)
                         {
                             base.SysCleanupSubAssistant.ThrottleStoreCallAndCheckForShutdown(base.MailboxDataForTags.MailboxSession.MailboxOwner);
                         }
                     }
                     if (auditLog.EstimatedLogEndTime < this.expirationTime && auditLog.LogFolderId is VersionedId)
                     {
                         list.Add(auditLog.LogFolderId as VersionedId);
                     }
                 }
                 if (list.Count > 0)
                 {
                     foreach (VersionedId itemId in list)
                     {
                         base.TagExpirationExecutor.AddToDoomedHardDeleteList(new ItemData(itemId, 0), false);
                     }
                 }
             }
         }
     }
 }