private bool CheckAndUpdateHashes(JunkEmailRule junkEmailRule, UpdateType currentUpdateType) { AddressHashes addressHashes = this.ComputeHashForMailbox(junkEmailRule, currentUpdateType); if (!this.CompareHashes(addressHashes, this.DataObject, currentUpdateType)) { byte[] array = addressHashes.GetBytes(); if (array.Length == 0) { array = null; } switch (currentUpdateType) { case UpdateType.SafeSenders: this.DataObject.SafeSendersHash = array; break; case UpdateType.SafeRecipients: this.DataObject.SafeRecipientsHash = array; break; case UpdateType.BlockedSenders: this.DataObject.BlockedSendersHash = array; break; } return(true); } return(false); }
// Token: 0x06000B9B RID: 2971 RVA: 0x0005148C File Offset: 0x0004F68C public static bool Edit(string oldEmail, string newEmail, JunkEmailListType junkEmailListType, UserContext userContext, bool isFromOptions, out string message) { if (string.IsNullOrEmpty(oldEmail)) { throw new ArgumentNullException("oldEmail", "oldEmail cannot be null or empty"); } if (string.IsNullOrEmpty(newEmail)) { throw new ArgumentNullException("newEmail", "newEmail cannot be null or empty"); } if (userContext == null) { throw new ArgumentNullException("userContext"); } bool flag = true; message = string.Empty; string empty = string.Empty; JunkEmailRule junkEmailRule = userContext.MailboxSession.JunkEmailRule; string[] email = new string[] { oldEmail }; JunkEmailUtilities.InternalRemove(junkEmailRule, email, junkEmailListType, userContext); if (!JunkEmailUtilities.InternalAdd(junkEmailRule, newEmail, junkEmailListType, userContext, isFromOptions, out message)) { flag = false; } if (flag) { junkEmailRule.Save(); } return(flag); }
// Token: 0x06000B9C RID: 2972 RVA: 0x00051524 File Offset: 0x0004F724 public static void SaveOptions(bool isEnabled, bool isContactsTrusted, bool safeListsOnly, UserContext userContext) { if (userContext == null) { throw new ArgumentNullException("userContext"); } JunkEmailRule junkEmailRule = userContext.MailboxSession.JunkEmailRule; junkEmailRule.IsEnabled = isEnabled; if (isEnabled) { if (userContext.IsFeatureEnabled(Feature.Contacts) && junkEmailRule.IsContactsFolderTrusted != isContactsTrusted) { if (isContactsTrusted) { Utilities.JunkEmailRuleSynchronizeContactsCache(junkEmailRule); } else { junkEmailRule.ClearContactsCache(); } } junkEmailRule.TrustedListsOnly = safeListsOnly; } junkEmailRule.Save(); userContext.RefreshIsJunkEmailEnabled(); }
private void SetTrustedList(MailboxJunkEmailConfiguration o, JunkEmailRule rule) { MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationTuple junkEmailValidationTuple = this.SetList(o.TrustedSendersAndDomains, rule.TrustedSenderEmailCollection, rule.TrustedSenderDomainCollection); if (junkEmailValidationTuple.Problem == MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsGood) { junkEmailValidationTuple = this.SetList(o.TrustedSendersAndDomains, rule.TrustedRecipientEmailCollection, rule.TrustedRecipientDomainCollection); } LocalizedString localizedString = LocalizedString.Empty; switch (junkEmailValidationTuple.Problem) { case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsUsersEmailOrDomain: localizedString = ServerStrings.JunkEmailTrustedListOwnersEmailAddressException(junkEmailValidationTuple.Address); goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsInternalToOrganization: localizedString = ServerStrings.JunkEmailTrustedListInternalToOrganizationException(junkEmailValidationTuple.Address); goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsDuplicate: localizedString = ServerStrings.JunkEmailTrustedListXsoDuplicateException(junkEmailValidationTuple.Address); goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsEmpty: localizedString = ServerStrings.JunkEmailTrustedListXsoEmptyException; goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsMalformatted: localizedString = ServerStrings.JunkEmailTrustedListXsoFormatException(junkEmailValidationTuple.Address); goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsNull: localizedString = ServerStrings.JunkEmailTrustedListXsoNullException; goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsTooBig: localizedString = ServerStrings.JunkEmailTrustedListXsoTooBigException(junkEmailValidationTuple.Address); goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsFull: localizedString = ServerStrings.JunkEmailTrustedListXsoTooManyException; goto IL_EB; case MailboxJunkEmailConfigurationDataProvider.JunkEmailValidationProblem.IsGood: goto IL_EB; } localizedString = ServerStrings.JunkEmailTrustedListXsoGenericException(junkEmailValidationTuple.Address); IL_EB: if (localizedString != LocalizedString.Empty) { PropertyValidationError propertyValidationError = new PropertyValidationError(localizedString, MailboxJunkEmailConfigurationSchema.TrustedSendersAndDomains, o.TrustedSendersAndDomains); throw new PropertyValidationException(localizedString.ToString(), propertyValidationError.PropertyDefinition, new PropertyValidationError[] { propertyValidationError }); } }
internal static JunkEmailCollection Create(JunkEmailRule junkRule, JunkEmailCollection.ListType listType, ICollection <string> invlidEntriesCollection) { return(new JunkEmailCollection { junkRule = junkRule, listType = listType, invlidEntriesCollection = invlidEntriesCollection }); }
private string[] CompileBlocked(JunkEmailRule rule) { HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); hashSet.UnionWith(rule.BlockedSenderEmailCollection); hashSet.UnionWith(rule.BlockedSenderDomainCollection); return(Array.ConvertAll <string, string>(hashSet.ToArray <string>(), (string s) => s.TrimStart(new char[] { '@' }))); }
private void SynchronizeTrustedLists(JunkEmailRule rule) { HashSet <string> hashSet = new HashSet <string>(rule.TrustedRecipientEmailCollection, StringComparer.OrdinalIgnoreCase); hashSet.UnionWith(rule.TrustedSenderEmailCollection); this.SetDelta(hashSet.ToArray <string>(), rule.TrustedRecipientEmailCollection, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetListWithoutValidation)); this.SetDelta(hashSet.ToArray <string>(), rule.TrustedSenderEmailCollection, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetListWithoutValidation)); HashSet <string> hashSet2 = new HashSet <string>(rule.TrustedRecipientDomainCollection, StringComparer.OrdinalIgnoreCase); hashSet2.UnionWith(rule.TrustedSenderDomainCollection); this.SetDelta(hashSet2.ToArray <string>(), rule.TrustedRecipientDomainCollection, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetListWithoutValidation)); this.SetDelta(hashSet2.ToArray <string>(), rule.TrustedSenderDomainCollection, new MailboxJunkEmailConfigurationDataProvider.JunkEmailAdditionStrategy(this.SetListWithoutValidation)); }
protected override void InternalSave(ConfigurableObject instance) { if (this.Session == null) { throw new DataSourceOperationException(ServerStrings.JunkEmailInvalidConstructionException); } this.TestForJunkEmailFolder(); MailboxJunkEmailConfiguration o = (MailboxJunkEmailConfiguration)instance; JunkEmailRule junkEmailRule = base.MailboxSession.JunkEmailRule; this.PrepareJunkEmailRule(o, junkEmailRule); this.SaveRule(junkEmailRule); }
// Token: 0x06000B99 RID: 2969 RVA: 0x00051350 File Offset: 0x0004F550 private static void InternalRemove(JunkEmailRule junkEmailRule, string[] email, JunkEmailListType junkEmailListType, UserContext userContext) { switch (junkEmailListType) { case JunkEmailListType.SafeSenders: for (int i = 0; i < email.Length; i++) { if (JunkEmailUtilities.IsDomain(ref email[i])) { junkEmailRule.TrustedSenderDomainCollection.Remove(email[i]); } else { junkEmailRule.TrustedSenderEmailCollection.Remove(email[i]); } } return; case JunkEmailListType.BlockedSenders: for (int j = 0; j < email.Length; j++) { if (JunkEmailUtilities.IsDomain(ref email[j])) { junkEmailRule.BlockedSenderDomainCollection.Remove(email[j]); } else { junkEmailRule.BlockedSenderEmailCollection.Remove(email[j]); } } return; case JunkEmailListType.SafeRecipients: for (int k = 0; k < email.Length; k++) { if (JunkEmailUtilities.IsDomain(ref email[k])) { junkEmailRule.TrustedRecipientDomainCollection.Remove(email[k]); } else { junkEmailRule.TrustedRecipientEmailCollection.Remove(email[k]); } } return; default: throw new OwaInvalidRequestException("Invalid list type"); } }
private AddressHashes ComputeHashForMailbox(JunkEmailRule junkEmailRule, UpdateType type) { AddressHashes addressHashes = new AddressHashes(); switch (type) { case UpdateType.SafeSenders: { if (this.IncludeDomains) { int num = this.UpdateAddressHashes(addressHashes, 3072, junkEmailRule.TrustedSenderDomainCollection); this.summary.SkippedSafeSenderDomains = junkEmailRule.TrustedSenderDomainCollection.Count - num; } if (junkEmailRule.IsContactsFolderTrusted) { int num2 = this.UpdateAddressHashes(addressHashes, 3072, junkEmailRule.TrustedContactsEmailCollection); this.summary.SkippedContacts = junkEmailRule.TrustedContactsEmailCollection.Count - num2; } int num3 = this.UpdateAddressHashes(addressHashes, 3072, junkEmailRule.TrustedSenderEmailCollection); this.summary.SkippedSafeSenders = junkEmailRule.TrustedSenderEmailCollection.Count - num3; break; } case UpdateType.SafeRecipients: { if (this.IncludeDomains) { int num4 = this.UpdateAddressHashes(addressHashes, 2048, junkEmailRule.TrustedRecipientDomainCollection); this.summary.SkippedSafeRecipientDomains = junkEmailRule.TrustedRecipientDomainCollection.Count - num4; } int num5 = this.UpdateAddressHashes(addressHashes, 2048, junkEmailRule.TrustedRecipientEmailCollection); this.summary.SkippedSafeRecipients = junkEmailRule.TrustedRecipientEmailCollection.Count - num5; break; } case UpdateType.BlockedSenders: { if (this.IncludeDomains) { int num6 = this.UpdateAddressHashes(addressHashes, 2048, junkEmailRule.BlockedSenderDomainCollection); this.summary.SkippedBlockedSenderDomains = junkEmailRule.BlockedSenderDomainCollection.Count - num6; } int num7 = this.UpdateAddressHashes(addressHashes, 2048, junkEmailRule.BlockedSenderEmailCollection); this.summary.SkippedBlockedSenders = junkEmailRule.BlockedSenderEmailCollection.Count - num7; break; } } return(addressHashes); }
private void SaveRule(JunkEmailRule rule) { try { rule.Save(); } catch (ObjectDisposedException) { throw new DataSourceTransientException(ServerStrings.JunkEmailObjectDisposedException); } catch (InvalidOperationException) { throw new DataSourceTransientException(ServerStrings.JunkEmailInvalidOperationException); } }
// Token: 0x06000B9A RID: 2970 RVA: 0x0005143C File Offset: 0x0004F63C public static void Remove(string[] email, JunkEmailListType junkEmailListType, UserContext userContext) { if (email == null || email.Length <= 0) { throw new ArgumentNullException("email", "email cannot be null or empty"); } if (userContext == null) { throw new ArgumentNullException("userContext"); } JunkEmailRule junkEmailRule = userContext.MailboxSession.JunkEmailRule; JunkEmailUtilities.InternalRemove(junkEmailRule, email, junkEmailListType, userContext); junkEmailRule.Save(); }
public override void Apply(MrsPSHandler psHandler, MailboxSession mailboxSession) { JunkEmailRule junkEmailRule = mailboxSession.JunkEmailRule; if (this.TrustedSenderDomain != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderDomainCollection, "TrustedSenderDomainCollection", mailboxSession.MailboxGuid, this.TrustedSenderDomain); } if (this.TrustedSenderEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderEmailCollection, "TrustedSenderEmailCollection", mailboxSession.MailboxGuid, this.TrustedSenderEmail); } if (this.BlockedSenderDomain != null) { this.AddEntriesToCollection(junkEmailRule.BlockedSenderDomainCollection, "BlockedSenderDomainCollection", mailboxSession.MailboxGuid, this.BlockedSenderDomain); } if (this.BlockedSenderEmail != null) { this.AddEntriesToCollection(junkEmailRule.BlockedSenderEmailCollection, "BlockedSenderEmailCollection", mailboxSession.MailboxGuid, this.BlockedSenderEmail); } if (this.TrustedRecipientDomain != null) { this.AddEntriesToCollection(junkEmailRule.TrustedRecipientDomainCollection, "TrustedRecipientDomainCollection", mailboxSession.MailboxGuid, this.TrustedRecipientDomain); } if (this.TrustedRecipientEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedRecipientEmailCollection, "TrustedRecipientEmailCollection", mailboxSession.MailboxGuid, this.TrustedRecipientEmail); } if (this.TrustedContactsEmail != null) { IRecipientSession adrecipientSession = mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid); if (adrecipientSession == null) { string itemList = this.TrustedContactsEmail.Aggregate((string result, string email) => result + ", " + email); throw new MailboxSettingsJunkMailErrorPermanentException("TrustedContactsEmail", itemList, "error getting RecipientSession"); } junkEmailRule.SynchronizeContactsCache(); foreach (string email2 in this.TrustedContactsEmail) { junkEmailRule.AddTrustedContact(email2, adrecipientSession); } } if (this.SendAsEmail != null) { this.AddEntriesToCollection(junkEmailRule.TrustedSenderEmailCollection, "TrustedSenderEmailCollection", mailboxSession.MailboxGuid, this.SendAsEmail); } junkEmailRule.Save(); }
protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize) { this.TestArguments <T>(filter, rootId); JunkEmailRule rule = base.MailboxSession.JunkEmailRule; MailboxJunkEmailConfiguration configuration = (MailboxJunkEmailConfiguration)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))); configuration.MailboxOwnerId = base.MailboxSession.MailboxOwner.ObjectId; configuration.Enabled = rule.IsEnabled; configuration.ContactsTrusted = rule.IsContactsFolderTrusted; configuration.TrustedListsOnly = rule.TrustedListsOnly; configuration.TrustedSendersAndDomains = this.CompileTrusted(rule); configuration.BlockedSendersAndDomains = this.CompileBlocked(rule); yield return((T)((object)configuration)); yield break; }
private void PrepareJunkEmailRule(MailboxJunkEmailConfiguration o, JunkEmailRule rule) { rule.IsEnabled = o.Enabled; rule.TrustedListsOnly = o.TrustedListsOnly; if (o.ContactsTrusted) { rule.SynchronizeContactsCache(); } else { rule.ClearContactsCache(); } this.SynchronizeTrustedLists(rule); this.SetBlockedList(o, rule); this.SetTrustedList(o, rule); }
// Token: 0x06000B4C RID: 2892 RVA: 0x00048F64 File Offset: 0x00047164 private byte[] GetSafeRecipientsHash(JunkEmailRule junkEmailRule, out bool oversized) { AddressHashes addressHashes = new AddressHashes(); int num = 0; int num2 = 0; oversized = false; if (Configuration.IncludeSafeDomains) { foreach (string text in junkEmailRule.TrustedRecipientDomainCollection) { if (addressHashes.Count >= Configuration.MaxSafeRecipients) { break; } num++; addressHashes.Add(text); JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Adding safe recipient domain {0} to list", text); } if (junkEmailRule.TrustedRecipientDomainCollection.Count != num) { oversized = true; JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <int>((long)this.GetHashCode(), "{0} safe recipient domain entries had to be skipped due to size constraints.", junkEmailRule.TrustedRecipientDomainCollection.Count - num); } } foreach (string text2 in junkEmailRule.TrustedRecipientEmailCollection) { if (addressHashes.Count >= Configuration.MaxSafeRecipients) { break; } num2++; addressHashes.Add(text2); JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Adding safe recipient {0} to list", text2); } if (junkEmailRule.TrustedRecipientEmailCollection.Count != num2) { oversized = true; JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <int>((long)this.GetHashCode(), "{0} safe recipient entries had to be skipped due to size constraints.", junkEmailRule.TrustedRecipientEmailCollection.Count - num2); } byte[] bytes = addressHashes.GetBytes(); if (bytes.Length == 0) { return(null); } return(bytes); }
// Token: 0x06000B4D RID: 2893 RVA: 0x000490DC File Offset: 0x000472DC private byte[] GetBlockedSendersHash(JunkEmailRule junkEmailRule, out bool oversized) { AddressHashes addressHashes = new AddressHashes(); int num = 0; int num2 = 0; oversized = false; foreach (string text in junkEmailRule.BlockedSenderDomainCollection) { if (addressHashes.Count >= Configuration.MaxBlockedSenders) { break; } num++; addressHashes.Add(text); JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Adding blocked sender domain {0} to list", text); } if (junkEmailRule.BlockedSenderDomainCollection.Count != num) { oversized = true; JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <int>((long)this.GetHashCode(), "{0} blocked sender domain entries had to be skipped due to size constraints.", junkEmailRule.BlockedSenderDomainCollection.Count - num); } foreach (string text2 in junkEmailRule.BlockedSenderEmailCollection) { if (addressHashes.Count >= Configuration.MaxBlockedSenders) { break; } num2++; addressHashes.Add(text2); JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Adding blocked sender {0} to list", text2); } if (junkEmailRule.BlockedSenderEmailCollection.Count != num2) { oversized = true; JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <int>((long)this.GetHashCode(), "{0} blocked sender entries had to be skipped due to size constraints.", junkEmailRule.BlockedSenderEmailCollection.Count - num2); } byte[] bytes = addressHashes.GetBytes(); if (bytes.Length == 0) { return(null); } return(bytes); }
// Token: 0x06000B98 RID: 2968 RVA: 0x000512F8 File Offset: 0x0004F4F8 public static bool Add(string email, JunkEmailListType junkEmailListType, UserContext userContext, bool isFromOptions, out string message) { if (string.IsNullOrEmpty(email)) { throw new ArgumentNullException("email", "email cannot be null or empty"); } if (userContext == null) { throw new ArgumentNullException("userContext"); } JunkEmailRule junkEmailRule = userContext.MailboxSession.JunkEmailRule; bool flag = JunkEmailUtilities.InternalAdd(junkEmailRule, email, junkEmailListType, userContext, isFromOptions, out message); if (flag) { junkEmailRule.Save(); } return(flag); }
// Token: 0x06000B31 RID: 2865 RVA: 0x00048204 File Offset: 0x00046404 private static void EnsureJunkEmailRule(MailboxSession session, MapiEvent mapiEvent) { if (session == null) { throw new ArgumentNullException("session"); } if (mapiEvent == null) { throw new ArgumentNullException("mapiEvent"); } if (!session.Capabilities.CanHaveJunkEmailRule) { JunkEmailOptionsAssistant.Tracer.TraceDebug <Guid>(0L, "Skipping mailbox {0} because it can't have a junk e-mail rule. Possibly an alternate mailbox.", session.MailboxOwner.MailboxInfo.MailboxGuid); return; } JunkEmailOptionsAssistant.Tracer.TraceDebug <Guid>(0L, "Ensuring junk e-mail rule for mailbox {0}", session.MailboxOwner.MailboxInfo.MailboxGuid); StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox); StoreObjectId defaultFolderId2 = session.GetDefaultFolderId(DefaultFolderType.JunkEmail); if (defaultFolderId == null || defaultFolderId2 == null) { JunkEmailOptionsAssistant.Tracer.TraceDebug <Guid>(0L, "Cannot create junk e-mail rule for mailbox {0} because either the inbox or junk e-mail folder does not exist.", session.MailboxOwner.MailboxInfo.MailboxGuid); return; } if (JunkEmailOptionsAssistant.IsFolderCreationEvent(mapiEvent) && !JunkEmailOptionsAssistant.IsInboxOrJunkFolder(mapiEvent.ItemEntryId, defaultFolderId, defaultFolderId2)) { JunkEmailOptionsAssistant.Tracer.TraceDebug(0L, "Created folder is not Inbox or Junk E-mail folder. Skipping uninteresting event."); return; } JunkEmailRule.JunkEmailStatus junkEmailRuleStatus = session.GetJunkEmailRuleStatus(); if (junkEmailRuleStatus != JunkEmailRule.JunkEmailStatus.None) { return; } JunkEmailOptionsAssistant.Tracer.TraceDebug <Guid>(0L, "Creating and enabling junk e-mail rule for mailbox {0}.", session.MailboxOwner.MailboxInfo.MailboxGuid); JunkEmailRule junkEmailRule = session.JunkEmailRule; junkEmailRule.IsEnabled = true; junkEmailRule.Save(); }
private void CheckAndCreateJunkEmailRule(MailboxSession session) { if (session == null) { throw new ArgumentNullException("session"); } StoreObjectId defaultFolderId = session.GetDefaultFolderId(DefaultFolderType.Inbox); StoreObjectId defaultFolderId2 = session.GetDefaultFolderId(DefaultFolderType.JunkEmail); if (defaultFolderId == null || defaultFolderId2 == null) { this.WriteWarning(Strings.CannotCreateJunkEmailRule(this.Identity.ToString())); return; } if (session.GetJunkEmailRuleStatus() == JunkEmailRule.JunkEmailStatus.None) { JunkEmailRule filteredJunkEmailRule = session.FilteredJunkEmailRule; filteredJunkEmailRule.IsEnabled = true; filteredJunkEmailRule.Save(); base.WriteObject(Strings.CreatedJunkEmailRule(this.Identity.ToString()).ToString()); } }
private void UpdateJunkEmailContacts() { if (this.junkEmailUpdates.Count > 0) { MailboxSession mailboxSession = base.Session as MailboxSession; if (mailboxSession != null && mailboxSession.LogonType != LogonType.Delegated && mailboxSession.Capabilities.CanHaveJunkEmailRule && !mailboxSession.MailboxOwner.ObjectId.IsNullOrEmpty()) { JunkEmailRule junkEmailRule = mailboxSession.JunkEmailRule; if (junkEmailRule.IsContactsFolderTrusted) { try { junkEmailRule.SynchronizeContactsCache(); junkEmailRule.Save(); } catch (JunkEmailValidationException) { } catch (DataSourceOperationException ex) { throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex, this, "Contact.UpdateJunkEmailContacts. Failed due to directory exception {0}.", new object[] { ex }); } catch (DataSourceTransientException ex2) { throw StorageGlobals.TranslateDirectoryException(ServerStrings.ADException, ex2, this, "Contact.UpdateJunkEmailContacts. Failed due to directory exception {0}.", new object[] { ex2 }); } } } } }
internal static JunkEmailCollection Create(JunkEmailRule junkRule, JunkEmailCollection.ListType listType) { return(JunkEmailCollection.Create(junkRule, listType, null)); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); bool flag = false; this.summary = default(UpdateSafeList.SafeListSummary); CmdletProxy.ThrowExceptionIfProxyIsNeeded(base.CurrentTaskContext, (ADUser)this.DataObject, false, this.ConfirmationMessage, null); try { ADUser aduser = this.DataObject as ADUser; if (aduser == null || (aduser.RecipientType != RecipientType.UserMailbox && aduser.RecipientType != RecipientType.MailUser)) { base.WriteError(new RecipientTypeInvalidException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser); } ExchangePrincipal mailboxOwner = ExchangePrincipal.FromADUser(base.SessionSettings, aduser); using (MailboxSession mailboxSession = MailboxSession.OpenAsAdmin(mailboxOwner, CultureInfo.InvariantCulture, "Client=Management;Action=Update-SafeList")) { if (!mailboxSession.Capabilities.CanHaveJunkEmailRule) { base.WriteError(new MailboxNotJunkRuleCapableException(this.Identity.ToString()), ErrorCategory.InvalidData, aduser); } else if (this.EnsureJunkEmailRule) { this.CheckAndCreateJunkEmailRule(mailboxSession); } else { JunkEmailRule filteredJunkEmailRule = mailboxSession.FilteredJunkEmailRule; switch (this.Type) { case UpdateType.SafeSenders: case UpdateType.SafeRecipients: case UpdateType.BlockedSenders: flag = this.CheckAndUpdateHashes(filteredJunkEmailRule, this.Type); break; case UpdateType.Both: if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients)) { flag = true; } if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders)) { flag = true; } break; case UpdateType.All: if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeRecipients)) { flag = true; } if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.SafeSenders)) { flag = true; } if (this.CheckAndUpdateHashes(filteredJunkEmailRule, UpdateType.BlockedSenders)) { flag = true; } break; } if (flag) { base.InternalProcessRecord(); if ((this.Type == UpdateType.SafeSenders || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedContacts > 0 || this.summary.SkippedSafeSenderDomains > 0 || this.summary.SkippedSafeSenders > 0)) { this.WriteWarning(Strings.SafeSendersNotUpdated(this.summary.SkippedContacts, this.summary.SkippedSafeSenders, this.summary.SkippedSafeSenderDomains, this.Identity.ToString())); } if ((this.Type == UpdateType.SafeRecipients || this.Type == UpdateType.Both || this.Type == UpdateType.All) && (this.summary.SkippedSafeRecipientDomains > 0 || this.summary.SkippedSafeRecipients > 0)) { this.WriteWarning(Strings.SafeRecipientsNotUpdated(this.summary.SkippedSafeRecipients, this.summary.SkippedSafeRecipientDomains, this.Identity.ToString())); } if ((this.Type == UpdateType.BlockedSenders || this.Type == UpdateType.All) && (this.summary.SkippedBlockedSenderDomains > 0 || this.summary.SkippedBlockedSenders > 0)) { this.WriteWarning(Strings.BlockedSendersNotUpdated(this.summary.SkippedBlockedSenders, this.summary.SkippedBlockedSenderDomains, this.Identity.ToString())); } } if (flag || !filteredJunkEmailRule.AllRestrictionsLoaded) { filteredJunkEmailRule.Save(); } } } } catch (JunkEmailValidationException ex) { TaskLogger.LogError(ex); base.WriteError(ex, ErrorCategory.InvalidData, this.DataObject); } catch (StorageTransientException ex2) { TaskLogger.LogError(ex2); base.WriteError(ex2, ErrorCategory.ReadError, this.DataObject); } catch (StoragePermanentException ex3) { TaskLogger.LogError(ex3); base.WriteError(ex3, ErrorCategory.InvalidOperation, this.DataObject); } finally { TaskLogger.LogExit(); } }
// Token: 0x06000B97 RID: 2967 RVA: 0x00050FAC File Offset: 0x0004F1AC private static bool InternalAdd(JunkEmailRule junkEmailRule, string email, JunkEmailListType junkEmailListType, UserContext userContext, bool isFromOptions, out string message) { bool result = true; message = string.Empty; string text = string.Empty; bool flag = JunkEmailUtilities.IsDomain(ref email); JunkEmailCollection.ValidationProblem validationProblem = JunkEmailCollection.ValidationProblem.NoError; try { switch (junkEmailListType) { case JunkEmailListType.SafeSenders: text = LocalizedStrings.GetNonEncoded(-644781195); if (flag) { validationProblem = junkEmailRule.TrustedSenderDomainCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } else if (JunkEmailUtilities.IsInternalToOrganization(email, userContext)) { message = string.Format(LocalizedStrings.GetNonEncoded(878888369), email, text); result = false; } else { validationProblem = junkEmailRule.TrustedSenderEmailCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } break; case JunkEmailListType.BlockedSenders: text = LocalizedStrings.GetNonEncoded(-145011736); if (flag) { validationProblem = junkEmailRule.BlockedSenderDomainCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } else if (JunkEmailUtilities.IsInternalToOrganization(email, userContext)) { message = string.Format(LocalizedStrings.GetNonEncoded(878888369), email, text); result = false; } else { validationProblem = junkEmailRule.BlockedSenderEmailCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } break; case JunkEmailListType.SafeRecipients: text = LocalizedStrings.GetNonEncoded(-606405795); if (JunkEmailUtilities.IsUsersEmailOrDomain(email, flag, userContext)) { message = string.Format(LocalizedStrings.GetNonEncoded(-1238229754), text); result = false; } else if (flag) { validationProblem = junkEmailRule.TrustedRecipientDomainCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } else { validationProblem = junkEmailRule.TrustedRecipientEmailCollection.TryAdd(email); message = string.Format(LocalizedStrings.GetNonEncoded(-1801060492), email, text); } break; default: throw new OwaInvalidRequestException("Invalid list type"); } } catch (JunkEmailValidationException ex) { ExTraceGlobals.CoreTracer.TraceDebug(0L, "JunkEmailValidationException was caught by JunkEmailUtilities.InternalAdd."); validationProblem = ex.Problem; } finally { switch (validationProblem) { case JunkEmailCollection.ValidationProblem.NoError: case JunkEmailCollection.ValidationProblem.Empty: goto IL_309; case JunkEmailCollection.ValidationProblem.Duplicate: message = string.Format(LocalizedStrings.GetNonEncoded(-1222968570), flag ? LocalizedStrings.GetNonEncoded(-520821858) : LocalizedStrings.GetNonEncoded(-1951590110), text); goto IL_309; case JunkEmailCollection.ValidationProblem.FormatError: message = string.Format(LocalizedStrings.GetNonEncoded(488857414), flag ? LocalizedStrings.GetNonEncoded(-520821858) : LocalizedStrings.GetNonEncoded(-1951590110), text, isFromOptions ? LocalizedStrings.GetNonEncoded(-2139153122) : string.Empty); result = false; goto IL_309; case JunkEmailCollection.ValidationProblem.TooBig: message = string.Format(LocalizedStrings.GetNonEncoded(1628764363), flag ? LocalizedStrings.GetNonEncoded(-520821858) : LocalizedStrings.GetNonEncoded(-1951590110), text); result = false; goto IL_309; case JunkEmailCollection.ValidationProblem.TooManyEntries: message = string.Format(LocalizedStrings.GetNonEncoded(1708451641), flag ? LocalizedStrings.GetNonEncoded(-520821858) : LocalizedStrings.GetNonEncoded(-1951590110), text); result = false; goto IL_309; } message = string.Format(LocalizedStrings.GetNonEncoded(1312248603), flag ? LocalizedStrings.GetNonEncoded(-520821858) : LocalizedStrings.GetNonEncoded(-1951590110), text); result = false; IL_309 :; } return(result); }
// Token: 0x06000B4A RID: 2890 RVA: 0x00048AC0 File Offset: 0x00046CC0 private void UpdateSafeLists(MailboxSession mailboxSession) { ADObjectId adobjectId = (mailboxSession.MailboxOwner != null) ? mailboxSession.MailboxOwner.ObjectId : null; if (adobjectId == null) { JunkEmailOptionsCommiterAssistant.Tracer.TraceError <MailboxSession>((long)this.GetHashCode(), "can't determine owner of mailbox {0}", mailboxSession); return; } if (TemplateTenantConfiguration.IsTemplateTenant(mailboxSession.MailboxOwner.MailboxInfo.OrganizationId)) { JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <string, Guid>((long)this.GetHashCode(), "Skipping mailbox {0} (GUID: {1}) because it belongs to a consumer tenant.", mailboxSession.MailboxOwner.MailboxInfo.DisplayName, mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid); return; } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(mailboxSession.MailboxOwner.MailboxInfo.OrganizationId), 318, "UpdateSafeLists", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\JunkEmailOptions\\JunkEmailOptionsCommiterAssistant.cs"); ADUser aduser = tenantOrRootOrgRecipientSession.Read(adobjectId) as ADUser; if (aduser == null) { JunkEmailOptionsCommiterAssistant.Tracer.TraceError <ADObjectId>((long)this.GetHashCode(), "can't read user object {0} from AD.", adobjectId); return; } JunkEmailRule filteredJunkEmailRule = mailboxSession.FilteredJunkEmailRule; bool flag = false; bool flag2 = false; bool flag3 = false; byte[] array = filteredJunkEmailRule.IsEnabled ? this.GetSafeSendersHash(filteredJunkEmailRule, out flag) : null; byte[] array2 = filteredJunkEmailRule.IsEnabled ? this.GetSafeRecipientsHash(filteredJunkEmailRule, out flag2) : null; byte[] array3 = filteredJunkEmailRule.IsEnabled ? this.GetBlockedSendersHash(filteredJunkEmailRule, out flag3) : null; bool flag4 = false; if (!ArrayComparer <byte> .Comparer.Equals(array, aduser.SafeSendersHash)) { aduser.SafeSendersHash = array; flag4 = true; } if (!ArrayComparer <byte> .Comparer.Equals(array2, aduser.SafeRecipientsHash)) { aduser.SafeRecipientsHash = array2; flag4 = true; } if (!ArrayComparer <byte> .Comparer.Equals(array3, aduser.BlockedSendersHash)) { aduser.BlockedSendersHash = array3; flag4 = true; } if (flag4) { JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Saving updated recipient object {0} to AD...", adobjectId); tenantOrRootOrgRecipientSession.Save(aduser); JunkEmailOptionsPerfCounters.TotalRecipientsUpdated.Increment(); JunkEmailOptionsCommiterAssistant.Tracer.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Recipient object {0} was successfully saved", adobjectId); if (flag || flag2 || flag3) { JunkEmailOptionsPerfCounters.TotalPartialUpdates.Increment(); } } Exception ex = null; try { if (flag4 || !filteredJunkEmailRule.AllRestrictionsLoaded) { filteredJunkEmailRule.Save(); } } catch (StoragePermanentException ex2) { ex = ex2; } catch (StorageTransientException ex3) { ex = ex3; } finally { if (ex != null) { JunkEmailOptionsCommiterAssistant.EventLogger.LogEvent(InfoWorkerEventLogConstants.Tuple_FailedToUpdateMailbox, null, new object[] { mailboxSession.MailboxGuid, ex }); } } }