private static void ClearThrottlingPolicyAssoicate(IRecipientSession session, ThrottlingPolicy policy)
        {
            QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.ThrottlingPolicy, policy.Id);

            ADRecipient[] array = session.Find <ADRecipient>(null, QueryScope.SubTree, filter, null, 100);
            if (array != null && array.Length > 0)
            {
                foreach (ADRecipient adrecipient in array)
                {
                    adrecipient.ThrottlingPolicy = null;
                    session.Save(adrecipient);
                }
            }
        }
示例#2
0
 // Token: 0x06000ED3 RID: 3795 RVA: 0x0002B3DD File Offset: 0x000295DD
 public ThrottlingPolicyIdParameter(ThrottlingPolicy policy) : base(policy.Id)
 {
 }
 private static ThrottlingPolicy GetWritableThrottlingPolicy(IConfigurationSession session, ThrottlingPolicy policy)
 {
     return(ThrottlingPolicyCache.ReadThrottlingPolicyFromAD(session, policy.Id, (IConfigurationSession session1, object id) => session1.Read <ThrottlingPolicy>(policy.Id)));
 }
示例#4
0
        // Token: 0x06001431 RID: 5169 RVA: 0x00049C88 File Offset: 0x00047E88
        internal static bool RevertExpiredThrottlingPolicyIfNeeded(IPowerShellBudget budget)
        {
            if (budget == null)
            {
                return(false);
            }
            bool result;

            using (new MonitoredScope("PowerShellThrottlingPolicyUpdater", "RevertExpiredThrottlingPolicyIfNeeded", AuthZLogHelper.AuthZPerfMonitors))
            {
                ThrottlingPolicy throttlingPolicy = null;
                try
                {
                    throttlingPolicy = ((EffectiveThrottlingPolicy)budget.ThrottlingPolicy).ThrottlingPolicy;
                    Match    match = Regex.Match(throttlingPolicy.Name, "^\\[(?<expiredtime>[0-9]{4}(-[0-9]{2}){2}T([0-9]{2}:){2}[0-9]{2})\\](?<orginalname>.+)", RegexOptions.Compiled);
                    DateTime t;
                    if (!match.Success)
                    {
                        result = false;
                    }
                    else if (!DateTime.TryParse(match.Groups["expiredtime"].Value, out t))
                    {
                        AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Unrecognized time format in throttling policy '{0}'.", throttlingPolicy.Name));
                        result = false;
                    }
                    else if (t > DateTime.UtcNow)
                    {
                        AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Throttlling policy '{0}' is not expired yet.", throttlingPolicy.Name));
                        result = false;
                    }
                    else
                    {
                        IConfigurationSession configuationSession      = PowerShellThrottlingPolicyUpdater.GetConfiguationSession(throttlingPolicy.OrganizationId);
                        ThrottlingPolicy      writableThrottlingPolicy = PowerShellThrottlingPolicyUpdater.GetWritableThrottlingPolicy(configuationSession, throttlingPolicy);
                        if (writableThrottlingPolicy == null || writableThrottlingPolicy.Name != throttlingPolicy.Name)
                        {
                            AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Throttlling policy '{0}' is updated and don't need to be expired.", throttlingPolicy.Name));
                            result = false;
                        }
                        else
                        {
                            string arg;
                            if (PowerShellThrottlingPolicyUpdater.RevertBackupThrottlingSettings(writableThrottlingPolicy, out arg))
                            {
                                writableThrottlingPolicy.Name = match.Groups["orginalname"].Value;
                                configuationSession.Save(writableThrottlingPolicy);
                                AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Revert throttling policy '{0}' to name: {1} and restore backup throttling value: {2}.", throttlingPolicy.Name, writableThrottlingPolicy.Name, arg));
                            }
                            else
                            {
                                PowerShellThrottlingPolicyUpdater.ClearThrottlingPolicyAssoicate(PowerShellThrottlingPolicyUpdater.GetRecipientSession(throttlingPolicy.OrganizationId), throttlingPolicy);
                                configuationSession.Delete(writableThrottlingPolicy);
                                AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Delete throttling policy '{0}' and clear associates with it.", throttlingPolicy.Name));
                            }
                            result = true;
                        }
                    }
                }
                catch (TransientException arg2)
                {
                    AuthZLogger.SafeAppendGenericInfo("PowerShellThrottlingPolicyUpdater", string.Format("Occur transient exception on revert throttling policy '{0}': {1}", (throttlingPolicy != null) ? throttlingPolicy.Name : string.Empty, arg2));
                    result = false;
                }
                catch (Exception ex)
                {
                    AuthZLogger.SafeAppendGenericError("PowerShellThrottlingPolicyUpdater", string.Format("Error on revert throttling policy '{0}': {1}", (throttlingPolicy != null) ? throttlingPolicy.Name : string.Empty, ex), KnownException.IsUnhandledException(ex));
                    result = false;
                }
            }
            return(result);
        }