protected override void InternalProcessRecord()
        {
            int  priority = 0;
            bool flag     = false;
            int  clientAccessRulesLimit = AppSettings.Current.ClientAccessRulesLimit;
            ClientAccessRulesPriorityManager clientAccessRulesPriorityManager = new ClientAccessRulesPriorityManager(ClientAccessRulesStorageManager.GetClientAccessRules((IConfigurationSession)base.DataSession));

            if (clientAccessRulesPriorityManager.ADClientAccessRules.Count >= clientAccessRulesLimit)
            {
                base.WriteError(new InvalidOperationException(RulesTasksStrings.ClientAccessRulesLimitError(clientAccessRulesLimit)), ErrorCategory.InvalidOperation, null);
            }
            if (!ClientAccessRulesStorageManager.IsADRuleValid(this.DataObject))
            {
                base.WriteError(new InvalidOperationException(RulesTasksStrings.ClientAccessRulesAuthenticationTypeInvalid), ErrorCategory.InvalidOperation, null);
            }
            this.DataObject.InternalPriority = clientAccessRulesPriorityManager.GetInternalPriority(this.Priority, this.DatacenterAdminsOnly, out priority, out flag);
            this.DataObject.RuleName         = this.DataObject.Name;
            this.DataObject.Priority         = priority;
            if (flag)
            {
                ClientAccessRulesStorageManager.SaveRules((IConfigurationSession)base.DataSession, clientAccessRulesPriorityManager.ADClientAccessRules);
            }
            base.CreateParentContainerIfNeeded(this.DataObject);
            base.InternalProcessRecord();
        }
 protected override void InternalProcessRecord()
 {
     if (!ClientAccessRulesStorageManager.IsADRuleValid(this.DataObject))
     {
         base.WriteError(new InvalidOperationException(RulesTasksStrings.ClientAccessRulesAuthenticationTypeInvalid), ErrorCategory.InvalidOperation, null);
     }
     if (this.DataObject.IsModified(ADObjectSchema.Name) || this.DataObject.IsModified(ADClientAccessRuleSchema.Priority))
     {
         List <ADClientAccessRule> list = new List <ADClientAccessRule>(ClientAccessRulesStorageManager.GetClientAccessRules((IConfigurationSession)base.DataSession));
         if (this.DataObject.IsModified(ADObjectSchema.Name))
         {
             foreach (ADClientAccessRule adclientAccessRule in list)
             {
                 if (!adclientAccessRule.Identity.Equals(this.DataObject.Identity) && adclientAccessRule.Name.Equals(this.DataObject.Name))
                 {
                     base.WriteError(new InvalidOperationException(RulesTasksStrings.ClientAccessRulesNameAlreadyInUse), ErrorCategory.InvalidOperation, null);
                 }
             }
         }
         if (this.DataObject.IsModified(ADClientAccessRuleSchema.Priority))
         {
             bool flag = false;
             ClientAccessRulesPriorityManager clientAccessRulesPriorityManager = new ClientAccessRulesPriorityManager(list);
             this.DataObject.InternalPriority = clientAccessRulesPriorityManager.GetInternalPriority(this.DataObject.Priority, this.DataObject, out flag);
             if (flag)
             {
                 ClientAccessRulesStorageManager.SaveRules((IConfigurationSession)base.DataSession, clientAccessRulesPriorityManager.ADClientAccessRules);
             }
         }
     }
     base.InternalProcessRecord();
 }
Beispiel #3
0
 public static IEnumerable <ADClientAccessRule> GetClientAccessRules(IConfigurationSession session)
 {
     if (session.SessionSettings.ConfigScopes == ConfigScopes.AllTenants)
     {
         throw new ArgumentException(Strings.AllTenantsScopedSessionNotSupported);
     }
     return(session.FindPaged <ADClientAccessRule>(null, ClientAccessRulesStorageManager.GetRulesADContainer(session), false, null, 0));
 }
        protected override void WriteResult <T>(IEnumerable <T> dataObjects)
        {
            Dictionary <ADObjectId, bool>    dictionary = new Dictionary <ADObjectId, bool>();
            ClientAccessRulesPriorityManager clientAccessRulesPriorityManager = new ClientAccessRulesPriorityManager(ClientAccessRulesStorageManager.GetClientAccessRules((IConfigurationSession)base.DataSession));

            if (this.Identity != null)
            {
                foreach (ADClientAccessRule adclientAccessRule in ((IEnumerable <ADClientAccessRule>)dataObjects))
                {
                    dictionary.Add(adclientAccessRule.Id, true);
                }
            }
            int num = 1;

            foreach (ADClientAccessRule adclientAccessRule2 in clientAccessRulesPriorityManager.ADClientAccessRules)
            {
                adclientAccessRule2.Priority = num++;
                if (this.Identity == null || dictionary.ContainsKey(adclientAccessRule2.Id))
                {
                    this.WriteResult(adclientAccessRule2);
                }
            }
        }
Beispiel #5
0
 public static bool IsADRuleValid(ADClientAccessRule rule)
 {
     return(ClientAccessRulesStorageManager.IsAuthenticationTypeParameterValid(rule) && rule.ValidateUserRecipientFilterParsesWithSchema());
 }
        private ClientAccessRuleCollection FetchClientAccessRulesCollection(IConfigurationSession session)
        {
            ClientAccessRulesPriorityManager clientAccessRulesPriorityManager = new ClientAccessRulesPriorityManager(ClientAccessRulesStorageManager.GetClientAccessRules(session));
            ClientAccessRuleCollection       clientAccessRuleCollection       = new ClientAccessRuleCollection((base.Identity == null) ? OrganizationId.ForestWideOrgId.ToString() : base.Identity.ToString());

            foreach (ADClientAccessRule adclientAccessRule in clientAccessRulesPriorityManager.ADClientAccessRules)
            {
                ClientAccessRule clientAccessRule = adclientAccessRule.GetClientAccessRule();
                if (clientAccessRule.Enabled == RuleState.Disabled)
                {
                    base.WriteVerbose(RulesTasksStrings.ClientAccessRuleWillBeConsideredEnabled(clientAccessRule.Name));
                    clientAccessRule.Enabled = RuleState.Enabled;
                }
                base.WriteVerbose(RulesTasksStrings.ClientAccessRuleWillBeAddedToCollection(clientAccessRule.Name));
                clientAccessRuleCollection.Add(clientAccessRule);
            }
            return(clientAccessRuleCollection);
        }