protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            this.CheckForDuplicateExistingDomain();
            AcceptedDomain acceptedDomain = new AcceptedDomain();

            acceptedDomain.Name       = this.Name;
            acceptedDomain.DomainName = new SmtpDomainWithSubdomains(this.DomainName, false);
            acceptedDomain.DomainType = this.DomainType;
            acceptedDomain.SetId(base.Session, this.DomainName.ToString());
            acceptedDomain.OrganizationId = base.CurrentOrganizationId;
            NewAcceptedDomain.ValidateDomainName(acceptedDomain, new Task.TaskErrorLoggingDelegate(this.WriteWrappedError));
            if (!this.DomainOwnershipVerified && this.AuthenticationType == AuthenticationType.Federated)
            {
                bool flag = false;
                AcceptedDomainIdParameter    acceptedDomainIdParameter = AcceptedDomainIdParameter.Parse("*");
                IEnumerable <AcceptedDomain> objects = acceptedDomainIdParameter.GetObjects <AcceptedDomain>(this.TenantCU.Id, base.Session);
                foreach (AcceptedDomain acceptedDomain2 in objects)
                {
                    SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(acceptedDomain2.DomainName.Domain.ToString(), true);
                    if (smtpDomainWithSubdomains.Match(this.DomainName.ToString()) == acceptedDomain2.DomainName.Domain.Length)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    base.WriteError(new OrganizationTaskException(Strings.ErrorTenantAdminsCanOnlyAddSubdomains(this.DomainName.ToString())), ErrorCategory.InvalidOperation, null);
                }
            }
            TaskLogger.LogExit();
        }
Beispiel #2
0
        private static bool IsInternal(string domainStringRepresentation, OrganizationId organizationId)
        {
            IConfigurationSession session = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 145, "IsInternal", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\EdgeExtensibility\\IsInternalResolver.cs");
            ADPagedReader <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain> acceptedDomains = null;

            ADNotificationAdapter.RunADOperation(delegate()
            {
                acceptedDomains = session.FindAllPaged <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain>();
            }, 3);
            foreach (Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain acceptedDomain in acceptedDomains)
            {
                if (acceptedDomain.DomainType != AcceptedDomainType.ExternalRelay)
                {
                    SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(acceptedDomain.DomainName.Domain, acceptedDomain.DomainName.IncludeSubDomains || acceptedDomain.MatchSubDomains);
                    if (smtpDomainWithSubdomains.Match(domainStringRepresentation) >= 0)
                    {
                        return(true);
                    }
                }
            }
            ADPagedReader <DomainContentConfig> remoteDomains = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                remoteDomains = session.FindAllPaged <DomainContentConfig>();
            });
            foreach (DomainContentConfig domainContentConfig in remoteDomains)
            {
                if (domainContentConfig.IsInternal && domainContentConfig.DomainName.Match(domainStringRepresentation) >= 0)
                {
                    return(true);
                }
            }
            return(false);
        }