protected override void InternalProcessRecord() { if (this.AlwaysDeleteOutlookRulesBlob.IsPresent) { InboxRuleDataProvider inboxRuleDataProvider = (InboxRuleDataProvider)base.DataSession; inboxRuleDataProvider.SetAlwaysDeleteOutlookRulesBlob(new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } else if (!this.Force.IsPresent) { InboxRuleDataProvider inboxRuleDataProvider = (InboxRuleDataProvider)base.DataSession; inboxRuleDataProvider.ConfirmDeleteOutlookBlob = (() => base.ShouldContinue(Strings.WarningInboxRuleOutlookBlobExists)); } if (this.DataObject.FlaggedForAction != null) { InboxRuleDataProvider.CheckFlaggedAction(this.DataObject.FlaggedForAction, InboxRuleSchema.FlaggedForAction.Name, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (this.DataObject.ExceptIfFlaggedForAction != null) { InboxRuleDataProvider.CheckFlaggedAction(this.DataObject.ExceptIfFlaggedForAction, InboxRuleSchema.ExceptIfFlaggedForAction.Name, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (this.DataObject.SendTextMessageNotificationTo.Count > 0) { SmsSqmDataPointHelper.AddNotificationConfigDataPoint(SmsSqmSession.Instance, this.adUser.Id, this.adUser.LegacyExchangeDN, SMSNotificationType.Email); } ManageInboxRule.ProcessRecord(new Action(base.InternalProcessRecord), new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError), this.Identity); }
internal IList <string> GetSubscriptionEmailAddresses(IList <AggregationSubscriptionIdentity> subscriptions) { IList <string> result; InboxRuleDataProvider.TryGetSubscriptionEmailAddresses(this.provider.MailboxOwner, subscriptions, out result); return(result); }
public static AggregationSubscriptionIdentity[] ResolveSubscriptions(ICollection <AggregationSubscriptionIdentity> ids, ADUser mailboxOwner, ManageInboxRule.ThrowTerminatingErrorDelegate errorHandler) { if (ids == null || ids.Count == 0) { return(new AggregationSubscriptionIdentity[0]); } List <AggregationSubscriptionIdentity> list = new List <AggregationSubscriptionIdentity>(ids.Count); PimSubscriptionProxy[] allSubscriptions = InboxRuleDataProvider.GetAllSubscriptions(mailboxOwner); List <AggregationSubscriptionIdentity> list2 = new List <AggregationSubscriptionIdentity>(allSubscriptions.Length); foreach (PimSubscriptionProxy pimSubscriptionProxy in allSubscriptions) { list2.Add(pimSubscriptionProxy.Subscription.SubscriptionIdentity); } foreach (AggregationSubscriptionIdentity aggregationSubscriptionIdentity in ids) { if (!list2.Contains(aggregationSubscriptionIdentity)) { errorHandler(new LocalizedException(Strings.InvalidSubscription(aggregationSubscriptionIdentity.ToString())), ErrorCategory.InvalidArgument, null); } else if (!list.Contains(aggregationSubscriptionIdentity)) { list.Add(aggregationSubscriptionIdentity); } } return(list.ToArray()); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; if (this.FromMessageId != null && this.FromMessageId.RawOwner != null) { mailboxIdParameter = this.FromMessageId.RawOwner; } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } this.adUser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, null, base.SessionSettings, 867, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\InboxRule\\NewInboxRule.cs"); base.VerifyIsWithinScopes(TaskHelper.UnderscopeSessionToOrganization(tenantOrRootOrgRecipientSession, this.adUser.OrganizationId, true), this.adUser, true, new DataAccessTask <InboxRule> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); XsoMailboxDataProviderBase xsoMailboxDataProviderBase; if (this.FromMessageId != null) { xsoMailboxDataProviderBase = new MailMessageDataProvider(base.SessionSettings, this.adUser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, "New-InboxRule"); this.FromMessageId.InternalStoreObjectId = new MailboxStoreObjectId((ADObjectId)this.adUser.Identity, this.FromMessageId.RawStoreObjectId); } else { xsoMailboxDataProviderBase = new InboxRuleDataProvider(base.SessionSettings, this.adUser, "New-InboxRule"); } this.mailboxOwner = xsoMailboxDataProviderBase.MailboxSession.MailboxOwner.ObjectId.ToString(); return(xsoMailboxDataProviderBase); }
protected override void InternalProcessRecord() { if (this.FromMessageId != null) { if (!base.HasErrors) { this.WriteResult(this.DataObject); } } else { InboxRuleDataProvider inboxRuleDataProvider = (InboxRuleDataProvider)base.DataSession; if (this.AlwaysDeleteOutlookRulesBlob.IsPresent) { inboxRuleDataProvider.SetAlwaysDeleteOutlookRulesBlob(new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } else if (!inboxRuleDataProvider.IsAlwaysDeleteOutlookRulesBlob()) { if (!inboxRuleDataProvider.HandleOutlookBlob(this.Force, () => base.ShouldContinue(Strings.WarningInboxRuleOutlookBlobExists))) { return; } } ManageInboxRule.ProcessRecord(new Action(base.InternalProcessRecord), new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError), this.Name); } if (this.DataObject.SendTextMessageNotificationTo.Count > 0) { SmsSqmDataPointHelper.AddNotificationConfigDataPoint(SmsSqmSession.Instance, this.adUser.Id, this.adUser.LegacyExchangeDN, SMSNotificationType.Email); } }
protected override void InternalProcessRecord() { InboxRuleDataProvider inboxRuleDataProvider = (InboxRuleDataProvider)base.DataSession; if (this.AlwaysDeleteOutlookRulesBlob.IsPresent) { inboxRuleDataProvider.SetAlwaysDeleteOutlookRulesBlob(new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } else if (!inboxRuleDataProvider.IsAlwaysDeleteOutlookRulesBlob() && !inboxRuleDataProvider.HandleOutlookBlob(this.Force, () => base.ShouldContinue(Strings.WarningInboxRuleOutlookBlobExists))) { return; } ManageInboxRule.ProcessRecord(new Action(base.InternalProcessRecord), new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError), this.Identity); }
protected override IConfigDataProvider CreateSession() { MailboxIdParameter mailboxIdParameter = null; if (this.Identity != null) { if (this.Identity.InternalInboxRuleId != null) { mailboxIdParameter = new MailboxIdParameter(this.Identity.InternalInboxRuleId.MailboxOwnerId); } else { mailboxIdParameter = this.Identity.RawMailbox; } } if (mailboxIdParameter != null && this.Mailbox != null) { base.WriteError(new InvalidOperationException(Strings.ErrorConflictingMailboxes), ErrorCategory.InvalidOperation, this.Identity); } if (mailboxIdParameter == null) { ADObjectId executingUserId; base.TryGetExecutingUserId(out executingUserId); mailboxIdParameter = (this.Mailbox ?? MailboxTaskHelper.ResolveMailboxIdentity(executingUserId, new Task.ErrorLoggerDelegate(base.WriteError))); } ADUser aduser = (ADUser)base.GetDataObject <ADUser>(mailboxIdParameter, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorMailboxNotFound(mailboxIdParameter.ToString())), new LocalizedString?(Strings.ErrorMailboxNotUnique(mailboxIdParameter.ToString()))); if (this.Identity != null && this.Identity.InternalInboxRuleId == null) { this.Identity.InternalInboxRuleId = new InboxRuleId(aduser.Id, this.Identity.RawRuleName, this.Identity.RawRuleId); } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, null, base.SessionSettings, 150, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\InboxRule\\GetInboxRule.cs"); base.VerifyIsWithinScopes(TaskHelper.UnderscopeSessionToOrganization(tenantOrRootOrgRecipientSession, aduser.OrganizationId, true), aduser, true, new DataAccessTask <InboxRule> .ADObjectOutOfScopeString(Strings.ErrorCannotChangeMailboxOutOfWriteScope)); InboxRuleDataProvider inboxRuleDataProvider = new InboxRuleDataProvider(base.SessionSettings, aduser, "Get-InboxRule"); if (this.IncludeHidden) { inboxRuleDataProvider.IncludeHidden = true; } if (base.Fields.IsChanged("DescriptionTimeZone")) { inboxRuleDataProvider.DescriptionTimeZone = this.DescriptionTimeZone; } if (base.Fields.IsChanged("DescriptionTimeFormat")) { inboxRuleDataProvider.DescriptionTimeFormat = this.DescriptionTimeFormat; } return(inboxRuleDataProvider); }
protected override void InternalValidate() { base.InternalValidate(); InboxRuleDataProvider.ValidateInboxRuleProperties(this.DataObject, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); }
private void PrepareDataObjectFromParameters(InboxRule inboxRule) { if (base.Fields.IsModified(InboxRuleSchema.From)) { inboxRule.From = ManageInboxRule.ResolveRecipients(this.From, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ExceptIfFrom)) { inboxRule.ExceptIfFrom = ManageInboxRule.ResolveRecipients(this.ExceptIfFrom, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.HasClassification)) { inboxRule.HasClassification = ManageInboxRule.ResolveMessageClassifications(this.HasClassification, this.ConfigurationSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ExceptIfHasClassification)) { inboxRule.ExceptIfHasClassification = ManageInboxRule.ResolveMessageClassifications(this.ExceptIfHasClassification, this.ConfigurationSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.SentTo)) { inboxRule.SentTo = ManageInboxRule.ResolveRecipients(this.SentTo, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ExceptIfSentTo)) { inboxRule.ExceptIfSentTo = ManageInboxRule.ResolveRecipients(this.ExceptIfSentTo, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.CopyToFolder)) { inboxRule.CopyToFolder = ManageInboxRule.ResolveMailboxFolder(this.CopyToFolder, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADUser>), new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <MailboxFolder>), base.TenantGlobalCatalogSession, base.SessionSettings, this.adUser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ForwardAsAttachmentTo)) { inboxRule.ForwardAsAttachmentTo = ManageInboxRule.ResolveRecipients(this.ForwardAsAttachmentTo, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ForwardTo)) { inboxRule.ForwardTo = ManageInboxRule.ResolveRecipients(this.ForwardTo, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.MoveToFolder)) { inboxRule.MoveToFolder = ManageInboxRule.ResolveMailboxFolder(this.MoveToFolder, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADUser>), new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <MailboxFolder>), base.TenantGlobalCatalogSession, base.SessionSettings, this.adUser, (base.ExchangeRunspaceConfig == null) ? null : base.ExchangeRunspaceConfig.SecurityAccessToken, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.RedirectTo)) { inboxRule.RedirectTo = ManageInboxRule.ResolveRecipients(this.RedirectTo, new DataAccessHelper.GetDataObjectDelegate(base.GetDataObject <ADRecipient>), base.TenantGlobalCatalogSession, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.FromSubscription)) { inboxRule.FromSubscription = ManageInboxRule.ResolveSubscriptions(this.FromSubscription, this.adUser, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (base.Fields.IsModified(InboxRuleSchema.ExceptIfFromSubscription)) { inboxRule.ExceptIfFromSubscription = ManageInboxRule.ResolveSubscriptions(this.ExceptIfFromSubscription, this.adUser, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (this.FlaggedForAction != null) { InboxRuleDataProvider.CheckFlaggedAction(this.FlaggedForAction, InboxRuleSchema.FlaggedForAction.Name, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } if (this.ExceptIfFlaggedForAction != null) { InboxRuleDataProvider.CheckFlaggedAction(this.ExceptIfFlaggedForAction, InboxRuleSchema.ExceptIfFlaggedForAction.Name, new ManageInboxRule.ThrowTerminatingErrorDelegate(base.WriteError)); } }