internal void AddClientAccessRuleCollection(ClientAccessRuleCollection rules) { foreach (Rule rule in rules) { ClientAccessRule rule2 = (ClientAccessRule)rule; base.AddWithoutNameCheck(rule2); } }
protected override void SaveRuleAttributes(XmlWriter xmlWriter, Rule rule) { ClientAccessRule clientAccessRule = rule as ClientAccessRule; if (clientAccessRule != null && clientAccessRule.DatacenterAdminsOnly) { xmlWriter.WriteAttributeString(ClientAccessRuleSerializer.DatacenterAdminsOnlyAttributeName, clientAccessRule.DatacenterAdminsOnly.ToString()); } base.SaveRuleAttributes(xmlWriter, rule); }
public static ClientAccessRule FromADProperties(string xml, ObjectId identity, string name, int priority, bool enabled, bool datacenterAdminsOnly, bool populatePresentationProperties) { ClientAccessRule clientAccessRule = (ClientAccessRule)ClientAccessRuleParser.Instance.GetRule(xml); clientAccessRule.Identity = identity; clientAccessRule.Name = name; clientAccessRule.Priority = priority; clientAccessRule.Enabled = (enabled ? RuleState.Enabled : RuleState.Disabled); clientAccessRule.DatacenterAdminsOnly = datacenterAdminsOnly; if (populatePresentationProperties) { if (clientAccessRule.Actions.Count > 0) { clientAccessRule.Action = (ClientAccessRulesAction)Enum.Parse(typeof(ClientAccessRulesAction), clientAccessRule.Actions[0].ExternalName); } ClientAccessRule.FillParametersFromCondition(clientAccessRule, clientAccessRule.Condition, false); } return(clientAccessRule); }
private static void FillParametersFromCondition(ClientAccessRule rule, Condition condition, bool wasNegated) { if (condition is AndCondition) { AndCondition andCondition = condition as AndCondition; foreach (Condition condition2 in andCondition.SubConditions) { ClientAccessRule.FillParametersFromCondition(rule, condition2, wasNegated); } } if (condition is NotCondition) { ClientAccessRule.FillParametersFromCondition(rule, ((NotCondition)condition).SubCondition, !wasNegated); } if (condition is AnyOfClientIPAddressesOrRangesPredicate) { AnyOfClientIPAddressesOrRangesPredicate anyOfClientIPAddressesOrRangesPredicate = condition as AnyOfClientIPAddressesOrRangesPredicate; if (wasNegated) { rule.ExceptAnyOfClientIPAddressesOrRanges = anyOfClientIPAddressesOrRangesPredicate.TargetIpRanges.ToArray <IPRange>(); } else { rule.AnyOfClientIPAddressesOrRanges = anyOfClientIPAddressesOrRangesPredicate.TargetIpRanges.ToArray <IPRange>(); } } if (condition is AnyOfSourceTcpPortNumbersPredicate) { AnyOfSourceTcpPortNumbersPredicate anyOfSourceTcpPortNumbersPredicate = condition as AnyOfSourceTcpPortNumbersPredicate; if (wasNegated) { rule.ExceptAnyOfSourceTcpPortNumbers = anyOfSourceTcpPortNumbersPredicate.TargetPortRanges.ToArray <IntRange>(); } else { rule.AnyOfSourceTcpPortNumbers = anyOfSourceTcpPortNumbersPredicate.TargetPortRanges.ToArray <IntRange>(); } } if (condition is AnyOfProtocolsPredicate) { AnyOfProtocolsPredicate anyOfProtocolsPredicate = condition as AnyOfProtocolsPredicate; if (wasNegated) { rule.ExceptAnyOfProtocols = anyOfProtocolsPredicate.ProtocolList.ToArray <ClientAccessProtocol>(); } else { rule.AnyOfProtocols = anyOfProtocolsPredicate.ProtocolList.ToArray <ClientAccessProtocol>(); } } if (condition is UsernameMatchesAnyOfPatternsPredicate) { UsernameMatchesAnyOfPatternsPredicate usernameMatchesAnyOfPatternsPredicate = condition as UsernameMatchesAnyOfPatternsPredicate; if (wasNegated) { rule.ExceptUsernameMatchesAnyOfPatterns = usernameMatchesAnyOfPatternsPredicate.RegexPatterns.Select(new Func <Regex, string>(ClientAccessRulesUsernamePatternProperty.GetDisplayValue)).ToArray <string>(); } else { rule.UsernameMatchesAnyOfPatterns = usernameMatchesAnyOfPatternsPredicate.RegexPatterns.Select(new Func <Regex, string>(ClientAccessRulesUsernamePatternProperty.GetDisplayValue)).ToArray <string>(); } } if (condition is AnyOfAuthenticationTypesPredicate) { AnyOfAuthenticationTypesPredicate anyOfAuthenticationTypesPredicate = condition as AnyOfAuthenticationTypesPredicate; if (wasNegated) { rule.ExceptAnyOfAuthenticationTypes = anyOfAuthenticationTypesPredicate.AuthenticationTypeList.ToArray <ClientAccessAuthenticationMethod>(); } else { rule.AnyOfAuthenticationTypes = anyOfAuthenticationTypesPredicate.AuthenticationTypeList.ToArray <ClientAccessAuthenticationMethod>(); } } if (condition is UserRecipientFilterPredicate) { UserRecipientFilterPredicate userRecipientFilterPredicate = condition as UserRecipientFilterPredicate; if (!wasNegated) { rule.UserRecipientFilter = userRecipientFilterPredicate.UserRecipientFilter; } } }