internal static object RecipientDomainsGetter(IPropertyBag propertyBag) { MultiValuedProperty <SmtpDomainWithSubdomains> multiValuedProperty = null; MultiValuedProperty <string> multiValuedProperty2 = (MultiValuedProperty <string>)propertyBag[TenantOutboundConnectorSchema.RecipientDomains]; if (multiValuedProperty2 != null) { multiValuedProperty = new MultiValuedProperty <SmtpDomainWithSubdomains>(); foreach (string text in multiValuedProperty2) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = null; if (!SmtpDomainWithSubdomains.TryParse(text, out smtpDomainWithSubdomains)) { AddressSpace addressSpace = null; if (AddressSpace.TryParse(text, out addressSpace) && addressSpace.IsSmtpType) { smtpDomainWithSubdomains = addressSpace.DomainWithSubdomains; } } if (smtpDomainWithSubdomains != null) { multiValuedProperty.Add(smtpDomainWithSubdomains); } } } return(multiValuedProperty); }
private static bool IsInternal(string domainStringRepresentation, OrganizationId organizationId) { IConfigurationSession session = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 145, "IsInternal", "f:\\15.00.1497\\sources\\dev\\data\\src\\directory\\EdgeExtensibility\\IsInternalResolver.cs"); ADPagedReader <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain> acceptedDomains = null; ADNotificationAdapter.RunADOperation(delegate() { acceptedDomains = session.FindAllPaged <Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain>(); }, 3); foreach (Microsoft.Exchange.Data.Directory.SystemConfiguration.AcceptedDomain acceptedDomain in acceptedDomains) { if (acceptedDomain.DomainType != AcceptedDomainType.ExternalRelay) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(acceptedDomain.DomainName.Domain, acceptedDomain.DomainName.IncludeSubDomains || acceptedDomain.MatchSubDomains); if (smtpDomainWithSubdomains.Match(domainStringRepresentation) >= 0) { return(true); } } } ADPagedReader <DomainContentConfig> remoteDomains = null; ADNotificationAdapter.TryRunADOperation(delegate() { remoteDomains = session.FindAllPaged <DomainContentConfig>(); }); foreach (DomainContentConfig domainContentConfig in remoteDomains) { if (domainContentConfig.IsInternal && domainContentConfig.DomainName.Match(domainStringRepresentation) >= 0) { return(true); } } return(false); }
public static IEnumerable <string> BucketizeConnector(TenantInboundConnector connector) { if (connector == null) { throw new ArgumentNullException("connector"); } if (connector.SenderIPAddresses != null) { foreach (string ipKey in TenantInboundConnectorBucket.FindAllVariationsOfKeysBasedOnSenderIPAddresses(connector.SenderIPAddresses)) { yield return(ipKey); } } if (connector.TlsSenderCertificateName != null) { SmtpDomainWithSubdomains domain = connector.TlsSenderCertificateName.TlsCertificateName as SmtpDomainWithSubdomains; if (domain != null) { yield return(domain.Address); } else { yield return(connector.TlsSenderCertificateName.ToString()); } } yield break; }
public SyncConfig(SyncOrganization cu, SmtpDomain federatedNamespace, SmtpDomainWithSubdomains provisioningDomain) : base(cu) { if (cu == null) { throw new ArgumentNullException("The value of parameter cu is null!"); } if (cu.FederatedTenant && federatedNamespace == null) { throw new ArgumentNullException("The value of parameter federatedNamespace should not be null for a federated organization!"); } if (cu.ProvisioningDomain == null && provisioningDomain == null) { throw new ArgumentNullException("The value of parameter provisioningDomain is null!"); } if (cu.FederatedTenant) { this.FederatedNamespace = federatedNamespace; if (string.IsNullOrEmpty(this.FederatedIdentitySourceADAttribute)) { this[SyncConfigSchema.FederatedIdentitySourceADAttribute] = "objectGuid"; } } else if (string.IsNullOrEmpty(this.PasswordFilePath)) { this[SyncConfigSchema.PasswordFilePath] = "password.xml"; } if (cu.ProvisioningDomain == null) { this[SyncConfigSchema.ProvisioningDomain] = provisioningDomain; } }
object ICustomTextConverter.Parse(Type deservedType, string s, IFormatProvider provider) { if (deservedType != typeof(MultiValuedProperty <SmtpDomainWithSubdomains>)) { throw new NotSupportedException(); } if (string.IsNullOrEmpty(s)) { throw new FormatException(Strings.ValueCanNotBeEmpty); } MultiValuedProperty <SmtpDomainWithSubdomains> multiValuedProperty = new MultiValuedProperty <SmtpDomainWithSubdomains>(); foreach (string text in s.Split(new char[] { ',' })) { if (!string.IsNullOrEmpty(text)) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = SmtpDomainWithSubdomains.Parse(text); if (SmtpDomainWithSubdomains.StarDomain.Equals(smtpDomainWithSubdomains)) { throw new FormatException(Strings.DisallowStarDomainConstraintText); } if (!multiValuedProperty.Contains(smtpDomainWithSubdomains)) { multiValuedProperty.Add(smtpDomainWithSubdomains); } } } return(multiValuedProperty); }
protected override void WriteResult(IConfigurable dataObject) { TaskLogger.LogEnter(new object[] { dataObject.Identity, dataObject }); AcceptedDomain acceptedDomain = null; SyncOrganization syncOrganization = (SyncOrganization)dataObject; SmtpDomain federatedNamespace = null; SmtpDomainWithSubdomains provisioningDomain = null; if (syncOrganization.FederatedTenant) { acceptedDomain = this.ResolveDefaultAcceptedDomain(); federatedNamespace = acceptedDomain.DomainName.SmtpDomain; } if (syncOrganization.ProvisioningDomain == null) { if (syncOrganization.FederatedTenant) { provisioningDomain = acceptedDomain.DomainName; } else { acceptedDomain = this.ResolveDefaultAcceptedDomain(); provisioningDomain = acceptedDomain.DomainName; } } base.WriteResult(new SyncConfig((SyncOrganization)dataObject, federatedNamespace, provisioningDomain)); TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); this.CheckForDuplicateExistingDomain(); AcceptedDomain acceptedDomain = new AcceptedDomain(); acceptedDomain.Name = this.Name; acceptedDomain.DomainName = new SmtpDomainWithSubdomains(this.DomainName, false); acceptedDomain.DomainType = this.DomainType; acceptedDomain.SetId(base.Session, this.DomainName.ToString()); acceptedDomain.OrganizationId = base.CurrentOrganizationId; NewAcceptedDomain.ValidateDomainName(acceptedDomain, new Task.TaskErrorLoggingDelegate(this.WriteWrappedError)); if (!this.DomainOwnershipVerified && this.AuthenticationType == AuthenticationType.Federated) { bool flag = false; AcceptedDomainIdParameter acceptedDomainIdParameter = AcceptedDomainIdParameter.Parse("*"); IEnumerable <AcceptedDomain> objects = acceptedDomainIdParameter.GetObjects <AcceptedDomain>(this.TenantCU.Id, base.Session); foreach (AcceptedDomain acceptedDomain2 in objects) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(acceptedDomain2.DomainName.Domain.ToString(), true); if (smtpDomainWithSubdomains.Match(this.DomainName.ToString()) == acceptedDomain2.DomainName.Domain.Length) { flag = true; break; } } if (!flag) { base.WriteError(new OrganizationTaskException(Strings.ErrorTenantAdminsCanOnlyAddSubdomains(this.DomainName.ToString())), ErrorCategory.InvalidOperation, null); } } TaskLogger.LogExit(); }
public static void InsertDomain(this MultiValuedProperty <SmtpDomainWithSubdomains> domainsList, string domainName) { if (domainsList != null && !string.IsNullOrEmpty(domainName)) { SmtpDomainWithSubdomains domain = new SmtpDomainWithSubdomains(domainName); domainsList.InsertDomain(domain); } }
public static void Convert(DataRow dataRow) { foreach (object obj in dataRow.Table.Columns) { DataColumn dataColumn = (DataColumn)obj; Type type = dataColumn.ExtendedProperties["ExpectedType"] as Type; string text = dataRow[dataColumn] as string; if (type != null && dataRow[dataColumn].GetType() != type && text != null) { if (type == typeof(Unlimited <int>)) { dataRow[dataColumn] = Unlimited <int> .Parse(text); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { dataRow[dataColumn] = Unlimited <EnhancedTimeSpan> .Parse(text); } else if (type == typeof(EmailAddressPolicyPriority)) { dataRow[dataColumn] = EmailAddressPolicyPriority.Parse(text); } else if (type == typeof(SmtpDomainWithSubdomains)) { dataRow[dataColumn] = SmtpDomainWithSubdomains.Parse(text); } else if (type == typeof(SmtpAddress)) { dataRow[dataColumn] = SmtpAddress.Parse(text); } else if (type == typeof(ProxyAddress)) { dataRow[dataColumn] = ProxyAddress.Parse(text); } else if (type == typeof(MailboxId)) { dataRow[dataColumn] = MailboxId.Parse(text); } else if (type == typeof(UMLanguage)) { dataRow[dataColumn] = UMLanguage.Parse(text); } else { if (!(type == typeof(ExchangeObjectVersion))) { throw new ArgumentException(string.Format("Type {0} is not supported convert from string yet", type)); } Regex regex = new Regex("^(?<Major>\\d+)\\.(?<Minor>\\d+) \\((?<buildMajor>\\d+)\\.(?<buildMinor>\\d+)\\.(?<buildVersion>\\d+)\\.(?<buildRevison>\\d+)\\)$"); Match match = regex.Match(text); if (!match.Success) { throw new ArgumentException(string.Format("{0} is not a valid ExchangeObjectVersion", text)); } dataRow[dataColumn] = new ExchangeObjectVersion(byte.Parse(match.Result("${Major}")), byte.Parse(match.Result("${Minor}")), byte.Parse(match.Result("${buildMajor}")), byte.Parse(match.Result("${buildMinor}")), ushort.Parse(match.Result("${buildVersion}")), ushort.Parse(match.Result("${buildRevison}"))); } } } }
public object Convert(object valueObject) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = (SmtpDomainWithSubdomains)valueObject; if (!SmtpDomainWithSubdomains.StarDomain.Equals(smtpDomainWithSubdomains)) { return(smtpDomainWithSubdomains.Domain); } return(string.Empty); }
public OrganizationId Get(SmtpDomainWithSubdomains smtpDomainWithSubdomain) { DomainProperties domainProperties = DomainPropertyCache.Singleton.Get(smtpDomainWithSubdomain); if (domainProperties == null) { return(null); } return(domainProperties.OrganizationId); }
public OrganizationId Get(SmtpDomain smtpDomain) { if (smtpDomain == null) { throw new ArgumentNullException("smtpDomain"); } SmtpDomainWithSubdomains smtpDomainWithSubdomain = new SmtpDomainWithSubdomains(smtpDomain, false); return(this.Get(smtpDomainWithSubdomain)); }
public static void GetAcceptDomainPostAction(DataRow inputRow, DataTable dataTable, DataObjectStore store) { foreach (object obj in dataTable.Rows) { DataRow dataRow = (DataRow)obj; SmtpDomainWithSubdomains smtpDomainWithSubdomains = (SmtpDomainWithSubdomains)dataRow["AcceptDomainName"]; if (smtpDomainWithSubdomains != null) { dataRow["AcceptedName"] = smtpDomainWithSubdomains.Domain; } } }
public static SmtpDomainWithSubdomains GetShortestDomain(this MultiValuedProperty <SmtpDomainWithSubdomains> domainsList) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = null; if (domainsList != null) { foreach (SmtpDomainWithSubdomains smtpDomainWithSubdomains2 in domainsList) { int num = (smtpDomainWithSubdomains == null) ? int.MaxValue : smtpDomainWithSubdomains.ToString().Length; if (smtpDomainWithSubdomains2.ToString().Length < num) { smtpDomainWithSubdomains = smtpDomainWithSubdomains2; } } } return(smtpDomainWithSubdomains); }
// Token: 0x060012F6 RID: 4854 RVA: 0x0003E1EC File Offset: 0x0003C3EC internal static IEnumerable <SmtpDomainWithSubdomains> GetAcceptedDomains(OrganizationId organizationId, OrganizationId executingOrganizationId) { ProvisioningCache provisioningCache = ProvisioningCache.Instance; return(provisioningCache.TryAddAndGetOrganizationData <IEnumerable <SmtpDomainWithSubdomains> >(CannedProvisioningCacheKeys.OrganizationAcceptedDomains, organizationId, delegate() { ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), organizationId, executingOrganizationId, false); IConfigurationSession cfgSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, sessionSettings, 245, "GetAcceptedDomains", "f:\\15.00.1497\\sources\\dev\\Configuration\\src\\ObjectModel\\rbac\\AuthZPluginHelper.cs"); ADObjectId rootId = organizationId.ConfigurationUnit ?? provisioningCache.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.FirstOrgContainerId, () => cfgSession.GetOrgContainerId()); QueryFilter filter = new NotFilter(new BitMaskAndFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL)); ADPagedReader <AcceptedDomain> adpagedReader = cfgSession.FindPaged <AcceptedDomain>(rootId, QueryScope.SubTree, filter, null, 0); AcceptedDomain[] array = adpagedReader.ReadAllPages(); SmtpDomainWithSubdomains[] array2 = new SmtpDomainWithSubdomains[array.Length]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i].DomainName; } return array2; })); }
public static bool IsFederatedUser(this RbacPrincipal rbacPrincipal) { bool result = false; ExchangeRunspaceConfiguration rbacConfiguration = rbacPrincipal.RbacConfiguration; SmtpAddress executingUserPrimarySmtpAddress = rbacConfiguration.ExecutingUserPrimarySmtpAddress; if (!executingUserPrimarySmtpAddress.IsValidAddress) { string executingUserPrincipalName = rbacConfiguration.ExecutingUserPrincipalName; if (!string.IsNullOrEmpty(executingUserPrincipalName) && SmtpAddress.IsValidSmtpAddress(executingUserPrincipalName)) { executingUserPrimarySmtpAddress = new SmtpAddress(executingUserPrincipalName); } } if (executingUserPrimarySmtpAddress.IsValidAddress) { SmtpDomainWithSubdomains smtpDomainWithSubdomains = new SmtpDomainWithSubdomains(executingUserPrimarySmtpAddress.Domain); DomainCacheValue domainCacheValue = DomainCache.Singleton.Get(smtpDomainWithSubdomains, rbacConfiguration.OrganizationId); result = (domainCacheValue != null && domainCacheValue.AuthenticationType != null && domainCacheValue.AuthenticationType.Value == AuthenticationType.Federated); } return(result); }
private static bool ValidateIfConnectorsCanRouteDomains(IEnumerable <TenantOutboundConnector> connectors, IEnumerable <SmtpDomainWithSubdomains> acceptedDomains, out List <SmtpDomainWithSubdomains> domainsThatCannotBeRouted) { domainsThatCannotBeRouted = null; using (IEnumerator <SmtpDomainWithSubdomains> enumerator = acceptedDomains.GetEnumerator()) { while (enumerator.MoveNext()) { SmtpDomainWithSubdomains domain = enumerator.Current; bool flag = false; foreach (TenantOutboundConnector tenantOutboundConnector in connectors) { if (tenantOutboundConnector.Enabled && tenantOutboundConnector.ConnectorType == TenantConnectorType.OnPremises) { if (tenantOutboundConnector.AllAcceptedDomains) { return(true); } if (tenantOutboundConnector.RecipientDomains.Any((SmtpDomainWithSubdomains r) => new WildcardPattern(r.Address).Match(domain.Address) != -1)) { flag = true; break; } } } if (!flag) { if (domainsThatCannotBeRouted == null) { domainsThatCannotBeRouted = new List <SmtpDomainWithSubdomains>(); } domainsThatCannotBeRouted.Add(domain); } } } return(domainsThatCannotBeRouted == null); }
public static void InsertDomain(this MultiValuedProperty <SmtpDomainWithSubdomains> domainsList, SmtpDomainWithSubdomains domain) { if (domainsList != null && domain != null && !domainsList.Contains(domain)) { domainsList.Add(domain); } }
protected static object GetSingleProperty(object prop, Type type) { if (prop == null) { return(null); } object obj = null; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable <>)) { obj = MockObjectCreator.GetSingleProperty(prop, type.GetGenericArguments()[0]); } else if (type == typeof(ADObjectId) && prop is PSObject) { obj = new ADObjectId(((PSObject)prop).Members["DistinguishedName"].Value.ToString(), new Guid(((PSObject)prop).Members["ObjectGuid"].Value.ToString())); } else if (type == typeof(EnhancedTimeSpan)) { obj = EnhancedTimeSpan.Parse(prop.ToString()); } else if (type == typeof(Unlimited <EnhancedTimeSpan>)) { obj = Unlimited <EnhancedTimeSpan> .Parse(prop.ToString()); } else if (type == typeof(ByteQuantifiedSize)) { obj = ByteQuantifiedSize.Parse(prop.ToString()); } else if (type == typeof(Unlimited <ByteQuantifiedSize>)) { obj = Unlimited <ByteQuantifiedSize> .Parse(prop.ToString()); } else if (type == typeof(Unlimited <int>)) { obj = Unlimited <int> .Parse(prop.ToString()); } else if (type == typeof(ProxyAddress)) { obj = ProxyAddress.Parse(prop.ToString()); } else if (type == typeof(SmtpAddress)) { obj = new SmtpAddress(prop.ToString()); } else if (type == typeof(SmtpDomain)) { obj = SmtpDomain.Parse(prop.ToString()); } else if (type == typeof(CountryInfo)) { obj = CountryInfo.Parse(prop.ToString()); } else if (type == typeof(SharingPolicyDomain)) { obj = SharingPolicyDomain.Parse(prop.ToString()); } else if (type == typeof(ApprovedApplication)) { obj = ApprovedApplication.Parse(prop.ToString()); } else if (type == typeof(SmtpDomainWithSubdomains)) { obj = SmtpDomainWithSubdomains.Parse(prop.ToString()); } else if (type == typeof(UMLanguage)) { obj = UMLanguage.Parse(prop.ToString()); } else if (type == typeof(UMSmartHost)) { obj = UMSmartHost.Parse(prop.ToString()); } else if (type == typeof(ScheduleInterval)) { obj = ScheduleInterval.Parse(prop.ToString()); } else if (type == typeof(NumberFormat)) { obj = NumberFormat.Parse(prop.ToString()); } else if (type == typeof(DialGroupEntry)) { obj = DialGroupEntry.Parse(prop.ToString()); } else if (type == typeof(CustomMenuKeyMapping)) { obj = CustomMenuKeyMapping.Parse(prop.ToString()); } else if (type == typeof(HolidaySchedule)) { obj = HolidaySchedule.Parse(prop.ToString()); } else if (type == typeof(UMTimeZone)) { obj = UMTimeZone.Parse(prop.ToString()); } else if (type == typeof(ServerVersion)) { obj = ServerVersion.ParseFromSerialNumber(prop.ToString()); } else if (type == typeof(X509Certificate2)) { obj = new X509Certificate2(((PSObject)prop).Members["RawData"].Value as byte[]); } else if (type == typeof(LocalizedString)) { obj = new LocalizedString(prop.ToString()); } else if (type == typeof(ExchangeObjectVersion)) { obj = ExchangeObjectVersion.Parse(prop.ToString()); } else if (type == typeof(bool)) { obj = bool.Parse(prop.ToString()); } else if (type == typeof(SecurityPrincipalIdParameter)) { obj = new SecurityPrincipalIdParameter(prop.ToString()); } else if (type == typeof(ActiveDirectoryAccessRule)) { obj = (prop as ActiveDirectoryAccessRule); } else if (type == typeof(ObjectId)) { string text = prop.ToString(); if (!ADObjectId.IsValidDistinguishedName(text) && text.Contains("/")) { text = MockObjectCreator.ConvertDNFromTreeStructure(text); } obj = new ADObjectId(text); } else if (type.IsEnum) { try { obj = Enum.Parse(type, prop.ToString()); } catch (ArgumentException) { obj = Enum.GetValues(type).GetValue(0); } } return(obj ?? prop); }
public static bool ValidateIfAcceptedDomainCanBeRoutedUsingConnectors(IConfigDataProvider dataSession, SmtpDomainWithSubdomains acceptedDomain) { ArgumentValidator.ThrowIfNull("dataSession", dataSession); ArgumentValidator.ThrowIfNull("acceptedDomain", acceptedDomain); TenantOutboundConnector[] connectors = (TenantOutboundConnector[])dataSession.Find <TenantOutboundConnector>(null, null, true, null); List <SmtpDomainWithSubdomains> list; return(ManageTenantOutboundConnectors.ValidateIfConnectorsCanRouteDomains(connectors, new SmtpDomainWithSubdomains[] { acceptedDomain }, out list)); }
protected static void AddRecipientDomain(ref List <SmtpDomainWithSubdomains> recipientDomains, SmtpDomainWithSubdomains domain) { if (!recipientDomains.Contains(domain)) { recipientDomains.Add(domain); } }
protected static bool IsWildcardDomain(SmtpDomainWithSubdomains domain) { return(domain != null && domain.Equals(SmtpDomainWithSubdomains.StarDomain)); }