// Token: 0x0600607A RID: 24698 RVA: 0x00147E54 File Offset: 0x00146054
        public override ProvisioningValidationError[] Validate(ADProvisioningPolicy enforcementPolicy, IConfigurable readOnlyPresentationObject)
        {
            base.Validate(enforcementPolicy, readOnlyPresentationObject);
            ADObject adobject;

            if (readOnlyPresentationObject is ADPublicFolder)
            {
                adobject = (ADPublicFolder)readOnlyPresentationObject;
            }
            else
            {
                adobject = (MailEnabledRecipient)readOnlyPresentationObject;
            }
            Unlimited <int> fromValue = (Unlimited <int>)enforcementPolicy[base.CountQuotaProperty];

            if (!fromValue.IsUnlimited && (T)fromValue >= 0)
            {
                int  num = (T)fromValue;
                bool flag;
                if (num == 0)
                {
                    flag = true;
                }
                else
                {
                    string domainController = null;
                    if (base.Context != null && base.Context.UserSpecifiedParameters != null && base.Context.UserSpecifiedParameters.Contains("DomainController"))
                    {
                        object obj = base.Context.UserSpecifiedParameters["DomainController"];
                        if (obj != null)
                        {
                            domainController = obj.ToString();
                        }
                    }
                    ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), adobject.OrganizationId, null, false);
                    IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(domainController, true, ConsistencyMode.FullyConsistent, sessionSettings, 178, "Validate", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\Provisioning\\RecipientResourceCountQuota.cs");
                    flag = SystemAddressListMemberCount.IsQuotaExceded(tenantOrTopologyConfigurationSession, adobject.OrganizationId, base.SystemAddressListName, num);
                }
                if (flag)
                {
                    string          policyId = string.Format("{0}: {1}", enforcementPolicy.Identity.ToString(), base.CountQuotaProperty.Name);
                    LocalizedString description;
                    if (adobject.OrganizationalUnitRoot == null)
                    {
                        description = DirectoryStrings.ErrorExceededHosterResourceCountQuota(policyId, (readOnlyPresentationObject.GetType() == typeof(ADPublicFolder)) ? "MailPublicFolder" : ProvisioningHelper.GetProvisioningObjectTag(readOnlyPresentationObject.GetType()), num);
                    }
                    else
                    {
                        description = DirectoryStrings.ErrorExceededMultiTenantResourceCountQuota(policyId, (readOnlyPresentationObject.GetType() == typeof(ADPublicFolder)) ? "MailPublicFolder" : ProvisioningHelper.GetProvisioningObjectTag(readOnlyPresentationObject.GetType()), adobject.OrganizationalUnitRoot.Name, num);
                    }
                    return(new ProvisioningValidationError[]
                    {
                        new ProvisioningValidationError(description, ExchangeErrorCategory.ServerOperation, null)
                    });
                }
            }
            return(null);
        }
            public int GetMailboxCount(OrganizationId organizationId, IConfigurationSession configSession)
            {
                int?mailboxCountFromCache = this.GetMailboxCountFromCache(organizationId.ConfigurationUnit);

                if (mailboxCountFromCache == null)
                {
                    mailboxCountFromCache = new int?(SystemAddressListMemberCount.GetCount(configSession, organizationId, "All Mailboxes(VLV)", false));
                    this.organizationCache[organizationId.ConfigurationUnit] = new UpgradeBucketTaskHelper.OrganizationMailboxCountCache.OrganizationCountCacheEntry
                    {
                        WhenRead     = ExDateTime.Now,
                        MailboxCount = mailboxCountFromCache.Value
                    };
                }
                return(mailboxCountFromCache.Value);
            }
        // Token: 0x060010DD RID: 4317 RVA: 0x00062B48 File Offset: 0x00060D48
        internal void GetTenantRecipientCount(out int mailboxCount, out int contactCount, out int mailUserCount)
        {
            this.Logger.TraceDebug(this, "GetOrganizationRecipientCount", new object[0]);
            mailboxCount  = 0;
            contactCount  = 0;
            mailUserCount = 0;
            ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), this.OrgId, null, false);
            IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 227, "GetTenantRecipientCount", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\DirectoryProcessor\\OrgMailboxScaleOutHelper.cs");

            mailboxCount  = SystemAddressListMemberCount.GetCount(tenantOrTopologyConfigurationSession, this.OrgId, "All Mailboxes(VLV)", true);
            contactCount  = SystemAddressListMemberCount.GetCount(tenantOrTopologyConfigurationSession, this.OrgId, "All Contacts(VLV)", true);
            mailUserCount = SystemAddressListMemberCount.GetCount(tenantOrTopologyConfigurationSession, this.OrgId, "All Mail Users(VLV)", true);
            this.Logger.TraceDebug(this, "GetOrganizationRecipientCount - Mailbox count='{0}', Contact count='{1}', Mail user count='{2}'", new object[]
            {
                mailboxCount,
                contactCount,
                mailUserCount
            });
        }
 protected override void WriteResult(IConfigurable dataObject)
 {
     TaskLogger.LogEnter(new object[]
     {
         dataObject.Identity,
         dataObject
     });
     if (this.Status)
     {
         RecipientEnforcementProvisioningPolicy recipientEnforcementProvisioningPolicy = dataObject as RecipientEnforcementProvisioningPolicy;
         if (recipientEnforcementProvisioningPolicy != null)
         {
             ADSessionSettings     sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.CurrentOrganizationId, base.ExecutingUserOrganizationId, false);
             IConfigurationSession configSession   = DirectorySessionFactory.Default.CreateTenantConfigurationSession(true, ConsistencyMode.PartiallyConsistent, sessionSettings, 74, "WriteResult", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\ProvisioningTasks\\Recipient\\GetRecipientEnforcementProvisioningPolicy.cs");
             recipientEnforcementProvisioningPolicy.MailboxCount          = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "All Mailboxes(VLV)", false));
             recipientEnforcementProvisioningPolicy.MailUserCount         = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "All Mail Users(VLV)", false));
             recipientEnforcementProvisioningPolicy.ContactCount          = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "All Contacts(VLV)", false));
             recipientEnforcementProvisioningPolicy.DistributionListCount = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "All Groups(VLV)", false));
             try
             {
                 recipientEnforcementProvisioningPolicy.TeamMailboxCount         = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "TeamMailboxes(VLV)", false));
                 recipientEnforcementProvisioningPolicy.PublicFolderMailboxCount = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "PublicFolderMailboxes(VLV)", false));
                 recipientEnforcementProvisioningPolicy.MailPublicFolderCount    = new int?(SystemAddressListMemberCount.GetCount(configSession, base.CurrentOrganizationId, "MailPublicFolders(VLV)", false));
             }
             catch (ADNoSuchObjectException)
             {
             }
         }
     }
     base.WriteResult(dataObject);
     TaskLogger.LogExit();
 }