示例#1
0
 protected override void InternalValidate()
 {
     TaskLogger.LogEnter();
     if (Server.IsSubscribedGateway(base.GlobalConfigSession))
     {
         base.WriteError(new CannotRunOnSubscribedEdgeException(), ErrorCategory.InvalidOperation, null);
     }
     base.InternalValidate();
     if (this.SkipDomainNameValidation)
     {
         if (!TemplateTenantConfiguration.IsTemplateTenant(base.OrganizationId))
         {
             base.WriteError(new CannotBypassDomainNameValidationException(), ErrorCategory.InvalidOperation, null);
         }
     }
     else
     {
         NewAcceptedDomain.ValidateDomainName(this.DataObject, new Task.TaskErrorLoggingDelegate(base.WriteError));
     }
     if (this.DataObject.DomainName.Equals(SmtpDomainWithSubdomains.StarDomain))
     {
         this.WriteWarning(Strings.WarnAboutStarAcceptedDomain);
     }
     NewAcceptedDomain.DomainAdditionValidator domainAdditionValidator = new NewAcceptedDomain.DomainAdditionValidator(this);
     domainAdditionValidator.ValidateAllPolicies();
     if (this.DataObject.InitialDomain)
     {
         NewAcceptedDomain.ValidateInitialDomain(this.DataObject, this.ConfigurationSession, new Task.TaskErrorLoggingDelegate(base.WriteError));
     }
     if (this.DataObject.DomainType == AcceptedDomainType.ExternalRelay && (Datacenter.IsMicrosoftHostedOnly(true) || Datacenter.IsForefrontForOfficeDatacenter()))
     {
         base.WriteError(new ExternalRelayDomainsAreNotAllowedInDatacenterAndFfoException(), ErrorCategory.InvalidOperation, null);
     }
     if (base.Fields.IsModified(AcceptedDomainSchema.CatchAllRecipient) && this.CatchAllRecipient != null)
     {
         this.resolvedCatchAllRecipient = (ADRecipient)base.GetDataObject <ADRecipient>(this.CatchAllRecipient, base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.CatchAllRecipientNotExists(this.CatchAllRecipient)), new LocalizedString?(Strings.CatchAllRecipientNotUnique(this.CatchAllRecipient)), ExchangeErrorCategory.Client);
     }
     AcceptedDomainUtility.ValidateCatchAllRecipient(this.resolvedCatchAllRecipient, this.DataObject, base.Fields.IsModified(AcceptedDomainSchema.CatchAllRecipient), new Task.TaskErrorLoggingDelegate(base.WriteError));
     AcceptedDomainUtility.ValidateIfOutboundConnectorToRouteDomainIsPresent(base.DataSession, this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning));
     AcceptedDomainUtility.ValidateMatchSubDomains(this.DataObject.MatchSubDomains, this.DataObject.DomainType, new Task.TaskErrorLoggingDelegate(base.WriteError));
     TaskLogger.LogExit();
 }
示例#2
0
        // 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
                    });
                }
            }
        }