private void RunClientAccessRules() { long ticks = DateTime.UtcNow.Ticks; ClientAccessRuleCollection clientAccessRuleCollection = this.FetchClientAccessRulesCollection(); ADRawEntry adrawEntry = this.FetchADRawEntry(this.User); string usernameFromADRawEntry = ClientAccessRulesUtils.GetUsernameFromADRawEntry(adrawEntry); base.WriteVerbose(RulesTasksStrings.TestClientAccessRuleFoundUsername(usernameFromADRawEntry)); ClientAccessRulesEvaluationContext context = new ClientAccessRulesEvaluationContext(clientAccessRuleCollection, usernameFromADRawEntry, new IPEndPoint(this.RemoteAddress, this.RemotePort), this.Protocol, this.AuthenticationType, adrawEntry, ObjectSchema.GetInstance <ClientAccessRulesRecipientFilterSchema>(), delegate(ClientAccessRulesEvaluationContext evaluationContext) { }, delegate(Rule rule, ClientAccessRulesAction action) { ObjectId identity = null; ClientAccessRule clientAccessRule = rule as ClientAccessRule; if (clientAccessRule != null) { identity = clientAccessRule.Identity; } this.WriteResult(new ClientAccessRulesEvaluationResult { Identity = identity, Name = rule.Name, Action = action }); }, ticks); clientAccessRuleCollection.Run(context); }
internal static ClientAccessRule GetRuleFromADProperties(IPropertyBag propertyBag) { if (string.IsNullOrEmpty((string)propertyBag[ADClientAccessRuleSchema.Xml])) { return(new ClientAccessRule((string)propertyBag[ADObjectSchema.RawName])); } return(ClientAccessRule.FromADProperties((string)propertyBag[ADClientAccessRuleSchema.Xml], null, (string)propertyBag[ADObjectSchema.RawName], (int)propertyBag[ADClientAccessRuleSchema.InternalPriority], (bool)propertyBag[ADClientAccessRuleSchema.EnabledBit], (bool)propertyBag[ADClientAccessRuleSchema.DatacenterAdminsOnlyBit], true)); }
internal static ADPropertyDefinition GetClientAccessRulePropertyDefinition <PropertyType, SingleType>(string name, PropertyType defaultValue, Func <ClientAccessRule, PropertyType> getter, Action <ClientAccessRule, PropertyType, IPropertyBag> setter, ADPropertyDefinitionFlags flags, PropertyDefinitionConstraint[] writeConstraints) { return(new ADPropertyDefinition(name, ExchangeObjectVersion.Exchange2012, typeof(SingleType), null, flags, defaultValue, PropertyDefinitionConstraint.None, writeConstraints, new ProviderPropertyDefinition[] { ADClientAccessRuleSchema.InternalPriority, ADClientAccessRuleSchema.RuleFlags, ADObjectSchema.RawName, ADClientAccessRuleSchema.Xml }, null, (IPropertyBag propertyBag) => getter(ADClientAccessRuleSchema.GetRuleFromADProperties(propertyBag)), delegate(object value, IPropertyBag propertyBag) { ClientAccessRule ruleFromADProperties = ADClientAccessRuleSchema.GetRuleFromADProperties(propertyBag); setter(ruleFromADProperties, (PropertyType)((object)value), propertyBag); propertyBag[ADClientAccessRuleSchema.Xml] = ruleFromADProperties.Xml; }, null, null)); }
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); }
public override void ReadData(IConfigurationSession configurationSession) { IEnumerable <ADClientAccessRule> enumerable = this.ReadRawData(configurationSession); this.ClientAccessRuleCollection = new ClientAccessRuleCollection(configurationSession.GetOrgContainerId().ToString()); this.estimatedSize = 0; if (VariantConfiguration.InvariantNoFlightingSnapshot.ClientAccessRulesCommon.ImplicitAllowLocalClientAccessRulesEnabled.Enabled && (null == configurationSession.SessionSettings.CurrentOrganizationId || OrganizationId.ForestWideOrgId.Equals(configurationSession.SessionSettings.CurrentOrganizationId))) { ClientAccessRule allowLocalClientAccessRule = ClientAccessRulesUtils.GetAllowLocalClientAccessRule(); if (allowLocalClientAccessRule != null) { this.ClientAccessRuleCollection.AddWithoutNameCheck(allowLocalClientAccessRule); this.estimatedSize += allowLocalClientAccessRule.GetEstimatedSize(); } } foreach (ADClientAccessRule adclientAccessRule in enumerable) { ClientAccessRule clientAccessRule = adclientAccessRule.GetClientAccessRule(); this.ClientAccessRuleCollection.AddWithoutNameCheck(clientAccessRule); this.estimatedSize += clientAccessRule.GetEstimatedSize(); } }
internal ClientAccessRule GetClientAccessRule() { return(ClientAccessRule.FromADProperties((string)this[ADClientAccessRuleSchema.Xml], this.Identity, base.Name, this.Priority, this.Enabled, this.DatacenterAdminsOnly, false)); }