private void ResolveTestAccount()
        {
            UserWithCredential testAccount;

            if (this.Identity != null)
            {
                testAccount            = default(UserWithCredential);
                testAccount.User       = this.GetUniqueADObject <ADUser>(this.Identity, this.RecipientSession, true);
                testAccount.Credential = this.MailboxCredential.GetNetworkCredential();
            }
            else
            {
                testAccount = this.GetMonitoringAccount();
            }
            if (SmtpAddress.IsValidSmtpAddress(testAccount.Credential.UserName))
            {
                testAccount.Credential.Domain = null;
            }
            else if (Datacenter.IsMultiTenancyEnabled())
            {
                testAccount.Credential.UserName = string.Format("{0}@{1}", testAccount.Credential.UserName, testAccount.Credential.Domain);
                testAccount.Credential.Domain   = null;
            }
            this.TestAccount = testAccount;
        }
예제 #2
0
        public override CapabilityEvaluationResult Evaluate(ADRawEntry adObject)
        {
            if (adObject == null)
            {
                throw new ArgumentNullException("adObject");
            }
            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Entering UMFeatureRestrictedCapabilityIdentifierEvaluator.Evaluate('{0}') CapabilityToCheck '{1}'.", adObject.GetDistinguishedNameOrName(), base.Capability.ToString());
            if (!Datacenter.IsMultiTenancyEnabled())
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - not datacenter mode.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            CountryInfo countryInfo = (CountryInfo)adObject[ADRecipientSchema.UsageLocation];

            if (null == countryInfo)
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "UMFeatureRestrictedCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'.  CapabilityToCheck '{2}' - UsageLocation is '<NULL>'.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            CountryList countryList = CountryListIdCache.Singleton.Get(UMFeatureRestrictedCapabilityIdentifierEvaluator.UMCountryListKey);

            if (countryList == null)
            {
                ExTraceGlobals.AccessCheckTracer.TraceWarning <string, string, string>((long)this.GetHashCode(), "UMFeatureRestrictedCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'.  CapabilityToCheck '{2}' - Cache lookup returned '<NULL>'.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.Yes.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.Yes);
            }
            if (countryList.Countries.Contains(countryInfo))
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "UMFeatureRestrictedCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'.  CapabilityToCheck '{2}'.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.No.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.No);
            }
            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "UMFeatureRestrictedCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'.  CapabilityToCheck '{2}'.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.Yes.ToString(), base.Capability.ToString());
            return(CapabilityEvaluationResult.Yes);
        }
예제 #3
0
 private void UpdateIntegratedMetabase(ADOwaVirtualDirectory dataObject)
 {
     if (Datacenter.IsMultiTenancyEnabled())
     {
         base.WriteError(new TaskException(Strings.IntegratedVDirNotSupported), ErrorCategory.InvalidOperation, null);
         return;
     }
     try
     {
         using (DirectoryEntry directoryEntry = IisUtility.FindWebDirObject(dataObject.MetabasePath, "Integrated"))
         {
             bool flag = false;
             if (dataObject.IntegratedFeaturesEnabled != null && dataObject.IntegratedFeaturesEnabled != null)
             {
                 flag = dataObject.IntegratedFeaturesEnabled.Value;
             }
             if (flag)
             {
                 IisUtility.SetAuthenticationMethod(directoryEntry, MetabasePropertyTypes.AuthFlags.Ntlm, true);
             }
             else
             {
                 IisUtility.SetAuthenticationMethod(directoryEntry, AuthenticationMethodFlags.None, true);
                 this.WriteWarning(Strings.IntegratedVDirDisabledWarning);
             }
             directoryEntry.CommitChanges();
         }
     }
     catch (WebObjectNotFoundException)
     {
         base.WriteError(new TaskException(Strings.IntegratedVDirNotFound), ErrorCategory.InvalidOperation, null);
     }
 }
 protected TenantStoreDataProvider(OrganizationId organizationId) : base(new LazilyInitialized <IExchangePrincipal>(() => TenantStoreDataProvider.GetTenantMailbox(organizationId ?? OrganizationId.ForestWideOrgId)), SpecialLogonType.SystemService, OpenAsAdminOrSystemServiceBudgetTypeType.RunAsBackgroundLoad)
 {
     if (organizationId == null && Datacenter.IsMultiTenancyEnabled())
     {
         throw new ArgumentNullException("organizationId", "organizationId can't be null in hosting environment.");
     }
 }
예제 #5
0
 public static void SetIfFederatedDisable(DataRow row, DataTable dataTable, DataObjectStore store)
 {
     if (!Datacenter.IsMultiTenancyEnabled() && store.GetDataObject("FederationTrust") == null)
     {
         dataTable.Rows[0]["FederationDisabled"] = true;
     }
 }
예제 #6
0
 private static void InitializeOlderLdapFilter()
 {
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList = new Dictionary <string, string[]>();
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultAllContacts, new string[]
     {
         "(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=contact)) ))"
     });
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultAllDistributionLists, new string[]
     {
         "(& (mailnickname=*) (| (objectCategory=group) ))"
     });
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultAllRooms, new string[]
     {
         "(& (mailnickname=*) (| (msExchResourceMetaData=ResourceType:Room) ))",
         "(&(mailnickname=*)(msExchResourceMetaData=ResourceType:Room))"
     });
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultAllUsers, new string[]
     {
         "(&(mailnickname=*)(|(&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))))"
     });
     CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultAllModernGroups, new string[]
     {
         "(&(!(!objectClass=user)))(objectCategory=person)(mailNickname=*)(msExchHomeServerName=*)(msExchRecipientTypeDetails=1099511627776))"
     });
     if (!Datacenter.IsMultiTenancyEnabled())
     {
         CannedAddressListsFilterHelper.ldapFiltersOfOlderAddressList.Add(CannedAddressListsFilterHelper.DefaultPublicFolders, new string[]
         {
             "(& (mailnickname=*) (| (objectCategory=publicFolder) ))"
         });
     }
 }
        public ExchangeConfigurationUnit GetExchangeConfigurationUnitByNameOrAcceptedDomain(string organizationName)
        {
            if (Datacenter.IsMultiTenancyEnabled())
            {
                ExchangeConfigurationUnit exchangeConfigurationUnitByName = this.GetExchangeConfigurationUnitByName(organizationName);
                if (exchangeConfigurationUnitByName != null)
                {
                    return(exchangeConfigurationUnitByName);
                }
            }
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, organizationName),
                new ComparisonFilter(ComparisonOperator.NotEqual, AcceptedDomainSchema.AcceptedDomainType, AcceptedDomainType.ExternalRelay)
            });

            AcceptedDomain[] array = base.Find <AcceptedDomain>(null, QueryScope.SubTree, filter, null, 1);
            if (array == null || array.Length == 0)
            {
                return(null);
            }
            ADObjectId entryId = array[0].Id.AncestorDN(3);

            return(base.Read <ExchangeConfigurationUnit>(entryId));
        }
예제 #8
0
        // Token: 0x0600067D RID: 1661 RVA: 0x00031744 File Offset: 0x0002F944
        protected override bool QueryIsEnabled()
        {
            if (!Datacenter.IsMultiTenancyEnabled())
            {
                EHAQuotaWarningEnforcer.Tracer.TraceDebug <EHAQuotaWarningEnforcer>((long)this.GetHashCode(), "{0}: All the checks below make sense only for DC and not for enterprise.", this);
                return(false);
            }
            if (!base.MailboxDataForTags.ElcUserInformation.ProcessEhaMigratedMessages)
            {
                EHAQuotaWarningEnforcer.Tracer.TraceDebug <EHAQuotaWarningEnforcer>((long)this.GetHashCode(), "{0}: Organization's ProcessEhaMigratedMessages settings is set to false. This mailbox will not be processed for migration messages", this);
                return(false);
            }
            TransportConfigContainer tenantTransportConfig = EHAQuotaWarningEnforcer.GetTenantTransportConfig(base.MailboxDataForTags.ElcUserTagInformation.ADUser.OrganizationId, this);

            if (tenantTransportConfig != null && !tenantTransportConfig.LegacyArchiveJournalingEnabled)
            {
                EHAQuotaWarningEnforcer.Tracer.TraceDebug <EHAQuotaWarningEnforcer>((long)this.GetHashCode(), "{0}: EHA Migration is already complete for this tenant, Skip Quota enforcer check.", this);
                return(false);
            }
            if (base.MailboxDataForTags.MailboxSession.MailboxOwner.MailboxInfo.IsArchive)
            {
                EHAQuotaWarningEnforcer.Tracer.TraceDebug <EHAQuotaWarningEnforcer>((long)this.GetHashCode(), "{0}: This is archive mailbox. This mailbox will not be processed for migration messages", this);
                return(false);
            }
            if (!this.IsMailboxInteresting())
            {
                EHAQuotaWarningEnforcer.Tracer.TraceDebug <EHAQuotaWarningEnforcer>((long)this.GetHashCode(), "{0}: This is not one of the eha mailboxes : journal ndr or confirmation mailbox. This mailbox will be skipped.", this);
                return(false);
            }
            return(true);
        }
예제 #9
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         LocalizedException ex = null;
         if (!Datacenter.IsMultiTenancyEnabled())
         {
             ex = base.ResetAutomatedCredentialsOnMailboxServer(this.localServer, true);
         }
         if (ex == null)
         {
             base.WriteMonitoringEvent(1000, this.MonitoringEventSource, EventTypeEnumeration.Success, Strings.AllActiveSyncTransactionsSucceeded);
         }
         else if (ex is CasHealthUserNotFoundException)
         {
             base.WriteMonitoringEvent(1008, this.MonitoringEventSource, EventTypeEnumeration.Warning, Strings.InstructResetCredentials(base.ShortErrorMsgFromException(ex)));
         }
         else
         {
             base.WriteMonitoringEvent(1001, this.MonitoringEventSource, EventTypeEnumeration.Error, base.ShortErrorMsgFromException(ex));
         }
     }
     finally
     {
         if (base.MonitoringContext)
         {
             base.WriteMonitoringData();
         }
         TaskLogger.LogExit();
     }
 }
 protected override IConfigDataProvider CreateSession()
 {
     if (Datacenter.IsMultiTenancyEnabled())
     {
         return(DirectorySessionFactory.Default.CreateTopologyConfigurationSession(base.DomainController, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 47, "CreateSession", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\Deployment\\InstallRootOrganizationContainer.cs"));
     }
     return(base.CreateSession());
 }
예제 #11
0
 protected override string GetRunspaceServerSettingsToken()
 {
     if (Datacenter.IsMultiTenancyEnabled() && RbacPrincipal.Current.IsAdmin && !OrganizationId.ForestWideOrgId.Equals(RbacPrincipal.Current.RbacConfiguration.OrganizationId))
     {
         return(RunspaceServerSettings.GetTokenForOrganization(RbacPrincipal.Current.RbacConfiguration.OrganizationId));
     }
     return(base.GetRunspaceServerSettingsToken());
 }
 protected override void InternalValidate()
 {
     base.InternalValidate();
     if (Datacenter.IsMultiTenancyEnabled() && this.DataObject.OrganizationId == OrganizationId.ForestWideOrgId && this.DataObject.AccessLevel != DeviceAccessLevel.Block)
     {
         base.WriteError(new ArgumentException(Strings.ErrorOnlyForestWideBlockIsAllowed), ErrorCategory.InvalidArgument, null);
     }
 }
        protected override bool InternalTryValidate(ADRawEntry adObject, out RuleValidationException validationException)
        {
            validationException = null;
            OrganizationValidationRuleDefinition organizationValidationRuleDefinition = base.RuleDefinition as OrganizationValidationRuleDefinition;

            if (!Datacenter.IsMultiTenancyEnabled())
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, bool>((long)this.GetHashCode(), "OrganizationValidationRule.InternalTryValidate('{0}') return '{1}'. - not datacenter mode.", adObject.GetDistinguishedNameOrName(), true);
                return(true);
            }
            OrganizationId            organizationId            = (OrganizationId)adObject[ADObjectSchema.OrganizationId];
            ADSessionSettings         sessionSettings           = OrganizationId.ForestWideOrgId.Equals(organizationId) ? ADSessionSettings.FromRootOrgScopeSet() : ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId);
            IConfigurationSession     session                   = DirectorySessionFactory.Default.CreateTenantConfigurationSession(adObject.OriginatingServer, true, ConsistencyMode.IgnoreInvalid, sessionSettings, 377, "InternalTryValidate", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\ValidationRules\\ValidationRule.cs");
            ExchangeConfigurationUnit exchangeConfigurationUnit = ProvisioningCache.Instance.TryAddAndGetOrganizationData <ExchangeConfigurationUnit>(CannedProvisioningCacheKeys.OrganizationCUContainer, organizationId, () => session.Read <ExchangeConfigurationUnit>(organizationId.ConfigurationUnit));

            if (exchangeConfigurationUnit == null)
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, bool>((long)this.GetHashCode(), "OrganizationValidationRule.InternalTryValidate('{0}') return '{1}'. - organization (ExchangeConfigurationUnit) object is not found.", adObject.GetDistinguishedNameOrName(), true);
                return(true);
            }
            foreach (ValidationRuleExpression validationRuleExpression in organizationValidationRuleDefinition.OverridingAllowExpressions)
            {
                bool flag = true;
                foreach (PropertyDefinition propertyDefinition in validationRuleExpression.QueryFilter.FilterProperties())
                {
                    if (!exchangeConfigurationUnit.propertyBag.Contains((ProviderPropertyDefinition)propertyDefinition))
                    {
                        ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ExpressionFilterValidationRule.InternalTryValidate({0}). Missing Property {1}.", exchangeConfigurationUnit.GetDistinguishedNameOrName(), propertyDefinition.Name);
                        flag = false;
                        break;
                    }
                }
                if (flag && OpathFilterEvaluator.FilterMatches(validationRuleExpression.QueryFilter, exchangeConfigurationUnit))
                {
                    ExTraceGlobals.AccessCheckTracer.TraceDebug <string, bool, string>((long)this.GetHashCode(), "OrganizationValidationRule.InternalTryValidate('{0}') return '{1}'. - matched filter: {2}.", adObject.GetDistinguishedNameOrName(), true, validationRuleExpression.QueryString);
                    return(true);
                }
            }
            foreach (ValidationRuleExpression validationRuleExpression2 in organizationValidationRuleDefinition.RestrictionExpressions)
            {
                bool flag2 = true;
                foreach (PropertyDefinition propertyDefinition2 in validationRuleExpression2.QueryFilter.FilterProperties())
                {
                    if (!exchangeConfigurationUnit.propertyBag.Contains((ProviderPropertyDefinition)propertyDefinition2))
                    {
                        ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "ExpressionFilterValidationRule.InternalTryValidate({0}). Missing Property {1}.", exchangeConfigurationUnit.GetDistinguishedNameOrName(), propertyDefinition2.Name);
                        flag2 = false;
                        break;
                    }
                }
                if (flag2 && OpathFilterEvaluator.FilterMatches(validationRuleExpression2.QueryFilter, exchangeConfigurationUnit))
                {
                    validationException = new RuleValidationException(base.GetValidationRuleErrorMessage(adObject, validationRuleExpression2.QueryString));
                    return(false);
                }
            }
            return(true);
        }
예제 #14
0
        private static string CheckDataCenterCompatibility()
        {
            string result = string.Empty;

            if (Datacenter.IsMultiTenancyEnabled())
            {
                result = Strings.BlockEMCInDataCenter;
            }
            return(result);
        }
예제 #15
0
        internal static NetworkCredential MakeCasCredential(NetworkCredential networkCredential)
        {
            NetworkCredential networkCredential2 = new NetworkCredential(networkCredential.UserName, networkCredential.Password, networkCredential.Domain);

            if (!Datacenter.IsMultiTenancyEnabled())
            {
                networkCredential2.UserName = SmtpAddress.Parse(networkCredential.UserName).Local;
            }
            return(networkCredential2);
        }
예제 #16
0
        public static string GetTenantId(OrganizationId organizationId)
        {
            if (!Datacenter.IsMultiTenancyEnabled())
            {
                return(null);
            }
            ADSessionSettings           sessionSettings            = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId);
            ITenantConfigurationSession tenantConfigurationSession = DirectorySessionFactory.Default.CreateTenantConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 94, "GetTenantId", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\OAuth\\OAuthConfigHelper.cs");
            ExchangeConfigurationUnit   exchangeConfigurationUnit  = tenantConfigurationSession.Read <ExchangeConfigurationUnit>(organizationId.ConfigurationUnit);

            return(exchangeConfigurationUnit.ExternalDirectoryOrganizationId);
        }
예제 #17
0
 internal string ToExternalDirectoryOrganizationId()
 {
     if (!Datacenter.IsMultiTenancyEnabled() || this == OrganizationId.ForestWideOrgId)
     {
         ExTraceGlobals.GLSTracer.TraceDebug <string>(0L, "[OrganizationIdConvertor.ToExternalDirectoryOrganizationId]: Returning string.Empty because {0}.", Datacenter.IsMultiTenancyEnabled() ? "orgId is ForestWideOrgId" : "multitenancy is not enabled");
         return(string.Empty);
     }
     if (this.externalDirectoryOrganizationId == null)
     {
         this.PopulateGuidsAndExternalDirectoryOrganizationId();
     }
     return(this.externalDirectoryOrganizationId.ToString());
 }
예제 #18
0
 private static void InitializeRecipientFilter()
 {
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList = new Dictionary <string, QueryFilter>();
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultAllContacts, CannedAddressListsFilterHelper.DefaultAllContactsFilter);
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultAllDistributionLists, CannedAddressListsFilterHelper.DefaultAllDistributionListsFilter);
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultAllRooms, CannedAddressListsFilterHelper.DefaultAllRoomsFilter);
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultAllUsers, CannedAddressListsFilterHelper.DefaultAllUsersFilter);
     CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultAllModernGroups, CannedAddressListsFilterHelper.DefaultAllModernGroupsFilter);
     if (!Datacenter.IsMultiTenancyEnabled())
     {
         CannedAddressListsFilterHelper.recipientFiltersOfAddressList.Add(CannedAddressListsFilterHelper.DefaultPublicFolders, CannedAddressListsFilterHelper.DefaultPublicFoldersFilter);
     }
 }
예제 #19
0
        public override CapabilityEvaluationResult Evaluate(ADRawEntry adObject)
        {
            if (adObject == null)
            {
                throw new ArgumentNullException("adObject");
            }
            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string>((long)this.GetHashCode(), "Entering MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') CapabilityToCheck '{1}'.", adObject.GetDistinguishedNameOrName(), base.Capability.ToString());
            if (!Datacenter.IsMultiTenancyEnabled())
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - not datacenter mode.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            ADRecipient      adrecipient      = adObject as ADRecipient;
            ReducedRecipient reducedRecipient = adObject as ReducedRecipient;

            if (adrecipient == null && reducedRecipient == null)
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - adObject in not ADRecipient or ReducedRecipient.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            if ((adrecipient == null || !adrecipient.IsDirSyncEnabled) && (reducedRecipient == null || !reducedRecipient.IsDirSyncEnabled))
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - recipient is not Dirsynced.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.No.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.No);
            }
            OrganizationId organizationId = (adrecipient != null) ? adrecipient.OrganizationId : reducedRecipient.OrganizationId;

            if (organizationId == null || OrganizationId.ForestWideOrgId.Equals(organizationId))
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - recipient does not belong to tenant scope.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            ExchangeConfigurationUnit exchangeConfigurationUnit = this.GetExchangeConfigurationUnit(organizationId);

            if (exchangeConfigurationUnit == null)
            {
                ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}' - recipient is not in tenant scope.", adObject.GetDistinguishedNameOrName(), CapabilityEvaluationResult.NotApplicable.ToString(), base.Capability.ToString());
                return(CapabilityEvaluationResult.NotApplicable);
            }
            CapabilityEvaluationResult capabilityEvaluationResult = exchangeConfigurationUnit.IsDirSyncEnabled ? CapabilityEvaluationResult.Yes : CapabilityEvaluationResult.No;

            ExTraceGlobals.AccessCheckTracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "MasteredOnPremiseCapabilityIdentifierEvaluator.Evaluate('{0}') return '{1}'. CapabilityToCheck '{2}'", adObject.GetDistinguishedNameOrName(), capabilityEvaluationResult.ToString(), base.Capability.ToString());
            return(capabilityEvaluationResult);
        }
        static ThrottlingPolicyDefaults()
        {
            bool flag = Datacenter.IsMultiTenancyEnabled();

            if (flag)
            {
                ThrottlingPolicyDefaults.SetAnonymousDefaults(1U, 120000U, 420000U, 720000U);
                ThrottlingPolicyDefaults.SetEasDefaults(4U, 480000U, 1800000U, 600000U, 100U, 20U, 180U);
                ThrottlingPolicyDefaults.SetEwsDefaults(27U, 300000U, 900000U, 3000000U, 20U);
                ThrottlingPolicyDefaults.SetImapDefaults(20U, 3600000U, 600000U, 600000U);
                ThrottlingPolicyDefaults.SetOutlookServiceDefaults(27U, 300000U, 900000U, 3000000U, 20U, 4U, 12U);
                ThrottlingPolicyDefaults.SetOwaDefaults(20U, 480000U, 1800000U, Unlimited <uint> .UnlimitedValue, 3U, 75000U, 375000U, 525000U);
                ThrottlingPolicyDefaults.SetPopDefaults(20U, 3600000U, 600000U, 600000U);
                ThrottlingPolicyDefaults.SetPowerShellDefaults(3U, 9U, 600000U, 1800000U, 3000000U, 400U, 5U, 25U, 50U, 120U, 60U, 200U, 5U, 18U, 60U);
                ThrottlingPolicyDefaults.SetPswsDefaults(3U, 25U, 5U);
                ThrottlingPolicyDefaults.SetRcaDefaults(40U, 150000U, 900000U, Unlimited <uint> .UnlimitedValue);
                ThrottlingPolicyDefaults.SetCpaDefaults(20U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
                ThrottlingPolicyDefaults.SetDiscoveryDefaults(2U, 5000U, 500U, 5000U, 100U, 200U, 25U, 10U, 32U, 10U);
                ThrottlingPolicyDefaults.SetGeneralDefaults(30U, 10000U, 10U);
                ThrottlingPolicyDefaults.SetPushNotificationDefaults(10U, 30000U, 120000U, 240000U, 10U, 6U, 600000U);
                ThrottlingPolicyDefaults.SetE4eSenderDefaults(200U, 4800000U, 18000000U, Unlimited <uint> .UnlimitedValue);
                ThrottlingPolicyDefaults.SetE4eRecipientDefaults(20U, 480000U, 1800000U, Unlimited <uint> .UnlimitedValue);
                ThrottlingPolicyDefaults.SetComplianceDefaults(10000U, 25U);
                return;
            }
            ThrottlingPolicyDefaults.SetAnonymousDefaults(1U, 120000U, 420000U, 720000U);
            ThrottlingPolicyDefaults.SetEasDefaults(10U, 480000U, 1800000U, 600000U, 100U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetEwsDefaults(27U, 300000U, 900000U, 3000000U, 5000U);
            ThrottlingPolicyDefaults.SetImapDefaults(Unlimited <uint> .UnlimitedValue, 3600000U, 600000U, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetOutlookServiceDefaults(27U, 300000U, 900000U, 3000000U, 5000U, 4U, 12U);
            ThrottlingPolicyDefaults.SetOwaDefaults(20U, 480000U, 1800000U, Unlimited <uint> .UnlimitedValue, 3U, 75000U, 375000U, 525000U);
            ThrottlingPolicyDefaults.SetPopDefaults(20U, 3600000U, 600000U, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetPowerShellDefaults(18U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetPswsDefaults(18U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetRcaDefaults(40U, 150000U, 900000U, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetCpaDefaults(20U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetDiscoveryDefaults(2U, 5000U, 500U, 5000U, 100U, 200U, 25U, 10U, 32U, 10U);
            ThrottlingPolicyDefaults.SetGeneralDefaults(Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetPushNotificationDefaults(20U, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, Unlimited <uint> .UnlimitedValue, 10U, 6U, 600000U);
            ThrottlingPolicyDefaults.SetE4eSenderDefaults(200U, 4800000U, 18000000U, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetE4eRecipientDefaults(20U, 480000U, 1800000U, Unlimited <uint> .UnlimitedValue);
            ThrottlingPolicyDefaults.SetComplianceDefaults(10000U, 25U);
        }
예제 #21
0
        private DomainCacheValue QueryFromADAndAddToCache(SmtpDomainWithSubdomains smtpDomainWithSubdomains, OrganizationId orgId)
        {
            ADSessionSettings sessionSettings = null;

            if (Datacenter.IsMultiTenancyEnabled())
            {
                try
                {
                    if (orgId != null)
                    {
                        sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId);
                    }
                    else
                    {
                        sessionSettings = ADSessionSettings.FromTenantAcceptedDomain(smtpDomainWithSubdomains.ToString());
                    }
                    goto IL_51;
                }
                catch (CannotResolveTenantNameException)
                {
                    sessionSettings = ADSessionSettings.FromRootOrgScopeSet();
                    goto IL_51;
                }
            }
            sessionSettings = ADSessionSettings.FromRootOrgScopeSet();
IL_51:
            IConfigurationSession configSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 159, "QueryFromADAndAddToCache", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ConfigurationCache\\DomainCache.cs");
            DomainCacheValue domainCacheValue = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                AcceptedDomain acceptedDomainByDomainName = configSession.GetAcceptedDomainByDomainName(smtpDomainWithSubdomains.ToString());
                if (acceptedDomainByDomainName != null)
                {
                    domainCacheValue = new DomainCacheValue();
                    domainCacheValue.OrganizationId     = acceptedDomainByDomainName.OrganizationId;
                    domainCacheValue.LiveIdInstanceType = acceptedDomainByDomainName.LiveIdInstanceType;
                    domainCacheValue.AuthenticationType = acceptedDomainByDomainName.AuthenticationType;
                    this.InsertLimitedSliding(acceptedDomainByDomainName.DomainName, domainCacheValue, DomainCache.slidingTimeOut.Value, DomainCache.absoluteTimeOut.Value, null);
                }
            });
            return(domainCacheValue);
        }
예제 #22
0
 static Util()
 {
     try
     {
         Util.isMicrosoftHostedOnly = Datacenter.IsMicrosoftHostedOnly(true);
     }
     catch (CannotDetermineExchangeModeException)
     {
         Util.isMicrosoftHostedOnly = false;
     }
     try
     {
         Util.isPartnerHostedOnly = Datacenter.IsPartnerHostedOnly(true);
     }
     catch (CannotDetermineExchangeModeException)
     {
         Util.isPartnerHostedOnly = false;
     }
     Util.isDataCenter = Datacenter.IsMultiTenancyEnabled();
 }
            public static bool IsTenantRelocationAllowed(string partitionFqdn)
            {
                if (string.IsNullOrEmpty(partitionFqdn))
                {
                    throw new ArgumentNullException("partitionFqdn");
                }
                if (!Datacenter.IsMultiTenancyEnabled())
                {
                    return(false);
                }
                ForestTenantRelocationsCache.RelocationsAllowedCache relocationsAllowedCache = ForestTenantRelocationsCache.RelocationsAllowedCache.GetInstance();
                ExpiringTenantRelocationsAllowedValue expiringTenantRelocationsAllowedValue;

                if (!relocationsAllowedCache.tenantRelocationsAllowed.TryGetValue(partitionFqdn, out expiringTenantRelocationsAllowedValue) || expiringTenantRelocationsAllowedValue.Expired)
                {
                    Organization rootOrgContainer = ADSystemConfigurationSession.GetRootOrgContainer(partitionFqdn, null, null);
                    expiringTenantRelocationsAllowedValue = new ExpiringTenantRelocationsAllowedValue(rootOrgContainer.TenantRelocationsAllowed);
                    relocationsAllowedCache.tenantRelocationsAllowed[partitionFqdn] = expiringTenantRelocationsAllowedValue;
                }
                return(expiringTenantRelocationsAllowedValue.Value);
            }
예제 #24
0
 static Globals()
 {
     using (Process currentProcess = Process.GetCurrentProcess())
     {
         Globals.processName              = currentProcess.MainModule.ModuleName;
         Globals.processId                = currentProcess.Id;
         Globals.processProcessName       = currentProcess.ProcessName;
         Globals.isExchangeTestExecutable = Globals.CheckExchangeTestExecutables(Globals.processProcessName);
     }
     Globals.SetProcessNameAppName();
     Globals.logger = new ExEventLog(Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.TopologyProviderTracer.Category, "MSExchange ADAccess");
     Globals.logger.SetEventPeriod(Globals.GetIntValueFromRegistry("LogPeriod", 900, 0));
     Globals.isDatacenterFlag              = Datacenter.IsMultiTenancyEnabled();
     Globals.isMicrosoftHostedOnly         = Datacenter.IsMicrosoftHostedOnly(true);
     Globals.testPassTypeValue             = Globals.GetValueFromRegistry <string>("SOFTWARE\\Microsoft\\Exchange_Test\\v15", "TestPassType", string.Empty, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer);
     Globals.forceLdapLatency              = (Globals.GetValueFromRegistry <int>("SOFTWARE\\Microsoft\\Exchange_Test\\v15", "ForceLdapLatency", 0, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer) > 0);
     Globals.TenantInfoCacheTime           = Globals.GetValueFromRegistry <int>("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess", "TenantInfoCacheTime", 1800, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer);
     Globals.RecipientInfoCacheTime        = Globals.GetValueFromRegistry <int>("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess", "RecipientInfoCacheTime", 300, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer);
     Globals.RecipientTokenGroupsCacheTime = Globals.GetValueFromRegistry <int>("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess", "RecipientTokenGroupsCacheTime", 900, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer);
     Globals.EnableNotification            = (Globals.GetValueFromRegistry <int>("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess", "EnableNotification", 1, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer) == 0);
     Globals.LdapConnectionPoolSize        = Globals.GetValueFromRegistry <int>("SYSTEM\\CurrentControlSet\\Services\\MSExchange ADAccess", "LdapConnectionPoolSize", 5, Microsoft.Exchange.Diagnostics.Components.Data.Directory.ExTraceGlobals.ADTopologyTracer);
 }
예제 #25
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            SharedConfigurationTaskHelper.VerifyIsNotTinyTenant(base.CurrentOrgState, new Task.ErrorLoggerDelegate(base.WriteError));
            IConfigurationSession session = (IConfigurationSession)base.DataSession;

            if (Datacenter.IsMultiTenancyEnabled())
            {
                if (this.AccessMethod != AvailabilityAccessMethod.OrgWideFB)
                {
                    base.ThrowTerminatingError(new InvalidAvailabilityAccessMethodException(), ErrorCategory.InvalidOperation, this.ForestName);
                }
                if (this.TargetAutodiscoverEpr == null)
                {
                    base.ThrowTerminatingError(new AvailabilityAddressSpaceInvalidTargetAutodiscoverEprException(), ErrorCategory.InvalidOperation, this.ForestName);
                }
            }
            if (this.AccessMethod == AvailabilityAccessMethod.OrgWideFBBasic && this.TargetAutodiscoverEpr == null)
            {
                base.ThrowTerminatingError(new AvailabilityAddressSpaceInvalidTargetAutodiscoverEprException(), ErrorCategory.InvalidOperation, this.ForestName);
            }
            this.DataObject.SetId(session, this.ForestName);
            PSCredential credentials = this.Credentials;

            if (credentials != null)
            {
                this.DataObject.UserName = credentials.UserName;
                this.DataObject.SetPassword(credentials.Password);
            }
            base.InternalValidate();
            if (base.HasErrors)
            {
                TaskLogger.LogExit();
                return;
            }
            TaskLogger.LogExit();
        }
예제 #26
0
        private DomainProperties QueryFromAD(SmtpDomainWithSubdomains smtpDomainWithSubdomains)
        {
            ADSessionSettings adsessionSettings = null;

            if (Datacenter.IsMultiTenancyEnabled())
            {
                try
                {
                    adsessionSettings = ADSessionSettings.FromTenantAcceptedDomain(smtpDomainWithSubdomains.ToString());
                    goto IL_5C;
                }
                catch (CannotResolveTenantNameException arg)
                {
                    DomainPropertyCache.Tracer.TraceError <SmtpDomainWithSubdomains, CannotResolveTenantNameException>((long)this.GetHashCode(), "Failed to resolve tenant with domain {0}. Error: {1}", smtpDomainWithSubdomains, arg);
                    adsessionSettings = ADSessionSettings.FromRootOrgScopeSet();
                    goto IL_5C;
                }
            }
            adsessionSettings = ADSessionSettings.FromRootOrgScopeSet();
IL_5C:
            DomainPropertyCache.Tracer.TraceDebug <SmtpDomainWithSubdomains, OrganizationId>((long)this.GetHashCode(), "The OrganizationId for domain {0} is {1}.", smtpDomainWithSubdomains, adsessionSettings.CurrentOrganizationId);
            IConfigurationSession configSession  = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, adsessionSettings, 219, "QueryFromAD", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\SystemConfiguration\\ConfigurationCache\\DomainPropertyCache.cs");
            DomainProperties      domainProperty = null;

            ADNotificationAdapter.TryRunADOperation(delegate()
            {
                AcceptedDomain acceptedDomainByDomainName = configSession.GetAcceptedDomainByDomainName(smtpDomainWithSubdomains.ToString());
                if (acceptedDomainByDomainName != null)
                {
                    domainProperty = new DomainProperties(smtpDomainWithSubdomains.SmtpDomain);
                    domainProperty.OrganizationId     = acceptedDomainByDomainName.OrganizationId;
                    domainProperty.LiveIdInstanceType = acceptedDomainByDomainName.LiveIdInstanceType;
                    DomainPropertyCache.Tracer.TraceDebug <AcceptedDomain, OrganizationId>((long)this.GetHashCode(), "Accepted domain {0} in organization {1}", acceptedDomainByDomainName, acceptedDomainByDomainName.OrganizationId);
                }
            });
            return(domainProperty);
        }
 protected void OutputMonitoringData()
 {
     if (this.MonitoringContext.IsPresent)
     {
         MonitoringData monitoringData = new MonitoringData();
         foreach (WebServicesTestOutcome webServicesTestOutcome in this.outcomes)
         {
             MonitoringEvent item = new MonitoringEvent("MSExchange Monitoring " + this.CmdletName, webServicesTestOutcome.MonitoringEventId, TestWebServicesTaskBase.EventTypeFromCasResultEnum(webServicesTestOutcome.Result), webServicesTestOutcome.ToString());
             monitoringData.Events.Add(item);
             if (Datacenter.IsMultiTenancyEnabled())
             {
                 EventLogEntryType entryType = EventLogEntryType.Information;
                 string            text;
                 if (webServicesTestOutcome.Result == CasTransactionResultEnum.Failure)
                 {
                     entryType = EventLogEntryType.Error;
                     text      = Strings.WebServicesTestErrorEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), webServicesTestOutcome.Latency.ToString(), webServicesTestOutcome.Error, webServicesTestOutcome.Verbose);
                 }
                 else if (webServicesTestOutcome.Result == CasTransactionResultEnum.Skipped)
                 {
                     entryType = EventLogEntryType.Warning;
                     text      = Strings.WebServicesTestEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), string.Empty);
                 }
                 else
                 {
                     text = Strings.WebServicesTestEventDetail(this.CmdletName, webServicesTestOutcome.Scenario.ToString(), webServicesTestOutcome.Result.ToString(), webServicesTestOutcome.Latency.ToString());
                 }
                 ExEventLog.EventTuple tuple = new ExEventLog.EventTuple((uint)webServicesTestOutcome.MonitoringEventId, 0, entryType, ExEventLog.EventLevel.Lowest, ExEventLog.EventPeriod.LogAlways);
                 TestWebServicesTaskBase.EventLog.LogEvent(tuple, string.Empty, new object[]
                 {
                     text
                 });
             }
         }
         base.WriteObject(monitoringData);
     }
 }
예제 #28
0
        private Exception InternalInvoke()
        {
            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(this.Uri);

            httpWebRequest.Credentials = this.Credentials;
            this.FillRequestProperties(httpWebRequest);
            this.WriteVerbose(Strings.VerboseServiceValidatorUrl(this.Name, this.Uri));
            if (Datacenter.IsMultiTenancyEnabled())
            {
                this.WriteVerbose(Strings.VerboseServiceValidatorCredential(this.Credentials.UserName, this.Credentials.Password));
            }
            else
            {
                this.WriteVerbose(Strings.VerboseServiceValidatorCredential(this.Credentials.UserName, "******"));
            }
            string message = null;

            using (MemoryStream memoryStream = new MemoryStream())
            {
                if (this.FillRequestStream(memoryStream))
                {
                    byte[] array = memoryStream.ToArray();
                    message = Encoding.UTF8.GetString(array);
                    using (Stream requestStream = httpWebRequest.GetRequestStream())
                    {
                        requestStream.Write(array, 0, array.Length);
                    }
                }
            }
            WebResponse webResponse = null;
            Exception   result;

            try
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                try
                {
                    webResponse = httpWebRequest.GetResponse();
                }
                finally
                {
                    this.Latency = stopwatch.ElapsedMilliseconds;
                    this.TraceRequest(ServiceValidatorBase.FormatHeaders(httpWebRequest.Headers));
                    this.TraceRequest(message);
                }
                this.TraceResponse(ServiceValidatorBase.FormatHeaders(webResponse.Headers));
                using (Stream responseStream = webResponse.GetResponseStream())
                {
                    using (StreamReader streamReader = new StreamReader(responseStream))
                    {
                        string text = streamReader.ReadToEnd();
                        if (this.TraceResponseBody)
                        {
                            this.TraceResponse(text);
                        }
                        byte[] bytes = Encoding.UTF8.GetBytes(text);
                        using (MemoryStream memoryStream2 = new MemoryStream(bytes))
                        {
                            result = this.ValidateResponse(memoryStream2);
                        }
                    }
                }
            }
            finally
            {
                if (webResponse != null)
                {
                    ((IDisposable)webResponse).Dispose();
                }
            }
            return(result);
        }
 internal bool ShouldPreventLastAdminRemoval(Task task, OrganizationId organization)
 {
     return(task.ExecutingUserOrganizationId != OrganizationId.ForestWideOrgId && Datacenter.IsMultiTenancyEnabled() && !this.IsOrganizationBeingRemoved(organization));
 }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            Organization organization = (Organization)base.PrepareDataObject();

            this.isMicrosoftExchangeRecipientChanged = (organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientEmailAddresses) || organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientEmailAddressPolicyEnabled) || organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientPrimarySmtpAddress) || organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientReplyRecipient));
            if (this.isMicrosoftExchangeRecipientChanged && this.microsoftExchangeRecipient == null)
            {
                this.WriteWarning(Strings.ErrorMicrosoftExchangeRecipientNotFound);
            }
            if (this.microsoftExchangeRecipient != null)
            {
                this.microsoftExchangeRecipient.DisplayName = ADMicrosoftExchangeRecipient.DefaultDisplayName;
                this.microsoftExchangeRecipient.DeliverToMailboxAndForward = false;
                if (organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientEmailAddresses))
                {
                    this.microsoftExchangeRecipient.EmailAddresses.CopyChangesFrom(organization.MicrosoftExchangeRecipientEmailAddresses);
                    if (Datacenter.IsMultiTenancyEnabled())
                    {
                        RecipientTaskHelper.ValidateSmtpAddress(this.ConfigurationSession, this.microsoftExchangeRecipient.EmailAddresses, this.microsoftExchangeRecipient, new Task.ErrorLoggerDelegate(base.WriteError), base.ProvisioningCache);
                    }
                    ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, this.microsoftExchangeRecipient.OrganizationId, base.CurrentOrganizationId, false);
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.TenantGlobalCatalogSession.DomainController, true, ConsistencyMode.PartiallyConsistent, base.TenantGlobalCatalogSession.NetworkCredential, sessionSettings, 632, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\SetOrganization.cs");
                    RecipientTaskHelper.ValidateEmailAddressErrorOut(tenantOrRootOrgRecipientSession, this.microsoftExchangeRecipient.EmailAddresses, this.microsoftExchangeRecipient, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerReThrowDelegate(this.WriteError));
                    if (this.microsoftExchangeRecipient.EmailAddresses.Count > 0)
                    {
                        RecipientTaskHelper.ValidateEmailAddress(base.TenantGlobalCatalogSession, this.microsoftExchangeRecipient.EmailAddresses, this.microsoftExchangeRecipient, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                    }
                }
                if (organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientPrimarySmtpAddress))
                {
                    this.microsoftExchangeRecipient.PrimarySmtpAddress = organization.MicrosoftExchangeRecipientPrimarySmtpAddress;
                }
                if (organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientReplyRecipient))
                {
                    this.microsoftExchangeRecipient.ForwardingAddress = organization.MicrosoftExchangeRecipientReplyRecipient;
                }
                if (organization.IsChanged(OrganizationSchema.MicrosoftExchangeRecipientEmailAddressPolicyEnabled))
                {
                    this.microsoftExchangeRecipient.EmailAddressPolicyEnabled = organization.MicrosoftExchangeRecipientEmailAddressPolicyEnabled;
                }
                ValidationError[] array = this.microsoftExchangeRecipient.Validate();
                for (int i = 0; i < array.Length; i++)
                {
                    this.WriteError(new DataValidationException(array[i]), ErrorCategory.InvalidData, null, i == array.Length - 1);
                }
                if (!ProvisioningLayer.Disabled)
                {
                    if (base.IsProvisioningLayerAvailable)
                    {
                        ProvisioningLayer.UpdateAffectedIConfigurable(this, RecipientTaskHelper.ConvertRecipientToPresentationObject(this.microsoftExchangeRecipient), false);
                    }
                    else
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorNoProvisioningHandlerAvailable), ErrorCategory.InvalidOperation, null);
                    }
                }
                organization.MicrosoftExchangeRecipientEmailAddresses            = this.microsoftExchangeRecipient.EmailAddresses;
                organization.MicrosoftExchangeRecipientPrimarySmtpAddress        = this.microsoftExchangeRecipient.PrimarySmtpAddress;
                organization.MicrosoftExchangeRecipientEmailAddressPolicyEnabled = this.microsoftExchangeRecipient.EmailAddressPolicyEnabled;
            }
            if (organization.IsChanged(OrganizationSchema.AdfsAuthenticationRawConfiguration) && AdfsAuthenticationConfig.Validate((string)organization[OrganizationSchema.AdfsAuthenticationRawConfiguration]))
            {
                this.WriteWarning(Strings.NeedIisRestartWarning);
            }
            TaskLogger.LogExit();
            return(organization);
        }