internal static IPEndPoint GetRemoteEndPointFromContext(HttpContext httpContext) { int remotePortFromContext = ClientAccessRulesUtils.GetRemotePortFromContext(httpContext); IPAddress remoteIPAddressFromContext = ClientAccessRulesUtils.GetRemoteIPAddressFromContext(httpContext); if (httpContext == null || remoteIPAddressFromContext == null || remotePortFromContext == 0) { return(null); } return(new IPEndPoint(remoteIPAddressFromContext, remotePortFromContext)); }
internal static ClientAccessRule GetAllowLocalClientAccessRule() { return(new ADClientAccessRule { Name = "[Allow Local Connections In-Memory Hardcoded Rule]", Priority = 1, Enabled = true, DatacenterAdminsOnly = true, Action = ClientAccessRulesAction.AllowAccess, AnyOfClientIPAddressesOrRanges = ClientAccessRulesUtils.GetAllLocalIPAddresses() }.GetClientAccessRule()); }
internal static string GetUsernameFromADRawEntry(ADRawEntry rawEntry) { SmtpAddress smtpAddress = SmtpAddress.Empty; if (rawEntry[ADRecipientSchema.WindowsLiveID] != null) { smtpAddress = (SmtpAddress)rawEntry[ADRecipientSchema.WindowsLiveID]; if (smtpAddress.IsValidAddress) { return(ClientAccessRulesUtils.GetUsernameFromWindowsLiveId(smtpAddress)); } } return(ClientAccessRulesUtils.GetUsernameFromIdInformation(smtpAddress, (SecurityIdentifier)rawEntry[ADRecipientSchema.MasterAccountSid], (SecurityIdentifier)rawEntry[ADMailboxRecipientSchema.Sid], rawEntry.Id)); }
internal static string GetUsernameFromIdInformation(SmtpAddress liveId, SecurityIdentifier masterAccountSid, SecurityIdentifier sid, ADObjectId adObjectId) { if (liveId.IsValidAddress) { return(ClientAccessRulesUtils.GetUsernameFromWindowsLiveId(liveId)); } if (masterAccountSid != null) { return(SidToAccountMap.Singleton.Get(masterAccountSid)); } if (sid != null) { return(SidToAccountMap.Singleton.Get(sid)); } return(ClientAccessRulesUtils.GetUsernameFromADObjectId(adObjectId)); }
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 static bool ShouldBlockConnection(OrganizationId organizationId, string username, ClientAccessProtocol protocol, IPEndPoint remoteEndpoint, ClientAccessAuthenticationMethod authenticationType, Action <ClientAccessRulesEvaluationContext> blockLoggerDelegate, Action <double> latencyLoggerDelegate) { return(ClientAccessRulesUtils.ShouldBlockConnection(organizationId, username, protocol, remoteEndpoint, authenticationType, null, blockLoggerDelegate, latencyLoggerDelegate)); }