// Token: 0x06000B96 RID: 2966 RVA: 0x00050E70 File Offset: 0x0004F070 private static bool IsUsersEmailOrDomain(string email, bool isDomain, UserContext userContext) { IRecipientSession recipientSession = Utilities.CreateADRecipientSession(Culture.GetUserCulture().LCID, true, ConsistencyMode.IgnoreInvalid, true, userContext); ADRecipient adrecipient = null; try { SmtpProxyAddress proxyAddress = new SmtpProxyAddress(userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString(), true); adrecipient = recipientSession.FindByProxyAddress(proxyAddress); } catch (NonUniqueRecipientException ex) { ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "IsUsersEmailOrDomain: NonUniqueRecipientException was thrown by FindByProxyAddress: {0}", ex.Message); } if (adrecipient == null) { return(false); } foreach (ProxyAddress proxyAddress2 in adrecipient.EmailAddresses) { if (proxyAddress2 != null && SmtpAddress.IsValidSmtpAddress(proxyAddress2.AddressString) && proxyAddress2.Prefix == ProxyAddressPrefix.Smtp) { string smtpAddress = ((SmtpProxyAddress)proxyAddress2).SmtpAddress; int num = smtpAddress.IndexOf('@'); int length = smtpAddress.Length; if (string.Equals((!isDomain || num == -1) ? smtpAddress : smtpAddress.Substring(num, length - num), email, StringComparison.OrdinalIgnoreCase)) { return(true); } } } return(false); }
private static bool TryGetADRecipient(Trace tracer, ADRecipientCache <TransportMiniRecipient> recipientCache, MailRecipient mailRecipient, out ADRecipient recipient) { recipient = null; ProxyAddress proxyAddress = new SmtpProxyAddress((string)mailRecipient.Email, true); TransportMiniRecipient recipientEntry = recipientCache.FindAndCacheRecipient(proxyAddress).Data; if (recipientEntry == null) { tracer.TraceWarning <RoutingAddress>(0L, "Could not find recipient entry for {0}", mailRecipient.Email); return(false); } ADRecipient tempRecipient = null; ADNotificationAdapter.TryRunADOperation(delegate() { SmtpAddress smtpAddress = new SmtpAddress(proxyAddress.AddressString); ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpAddress.Domain); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(null, null, LcidMapper.DefaultLcid, true, ConsistencyMode.IgnoreInvalid, null, sessionSettings, 178, "TryGetADRecipient", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\UM\\UMAgentUtil.cs"); tempRecipient = tenantOrRootOrgRecipientSession.Read(recipientEntry.Id); }); if (tempRecipient == null) { tracer.TraceWarning <ADObjectId>(0L, "Could not read recipient object for {0}", recipientEntry.Id); return(false); } recipient = tempRecipient; return(true); }
protected override void PrepareUserObject(ADUser user) { TaskLogger.LogEnter(); base.PrepareUserObject(user); if (this.WindowsLiveID != null && this.WindowsLiveID.SmtpAddress != SmtpAddress.Empty) { user.EmailAddressPolicyEnabled = false; SmtpProxyAddress item = new SmtpProxyAddress(this.WindowsLiveID.SmtpAddress.ToString(), false); if (!user.EmailAddresses.Contains(item)) { user.EmailAddresses.Add(item); } } if (user.ExchangeGuid == SoftDeletedTaskHelper.PredefinedExchangeGuid) { user.ExchangeGuid = user.PreviousExchangeGuid; if (!RecipientTaskHelper.IsExchangeGuidOrArchiveGuidUnique(user, ADMailboxRecipientSchema.ExchangeGuid, user.ExchangeGuid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client)) { user.ExchangeGuid = Guid.Empty; } user.PreviousExchangeGuid = Guid.Empty; } SoftDeletedTaskHelper.UpdateShadowWhenSoftDeletedProperty((IRecipientSession)base.DataSession, this.ConfigurationSession, base.CurrentOrganizationId, this.DataObject); this.DataObject.RecipientSoftDeletedStatus = 0; this.DataObject.WhenSoftDeleted = null; this.DataObject.InternalOnly = false; TaskLogger.LogExit(); }
private bool TryCreateExchangeGuidArray(out Guid[] exchangeGuid) { bool result = true; exchangeGuid = null; int num = 0; foreach (ADQueryResult adqueryResult in this.resultDictionary.Values) { string smtpAddress = adqueryResult.UserResultMapping.SmtpProxyAddress.SmtpAddress; Guid guid; if (!SmtpProxyAddress.TryDeencapsulateExchangeGuid(smtpAddress, out guid)) { result = false; exchangeGuid = null; break; } if (exchangeGuid == null) { exchangeGuid = new Guid[this.resultDictionary.Count]; } exchangeGuid[num] = guid; num++; } return(result); }
// Token: 0x0600147E RID: 5246 RVA: 0x00076708 File Offset: 0x00074908 protected override void InternalCopyFromModified(IProperty srcProperty) { string stringData = ((IStringProperty)srcProperty).StringData; Contact contact = base.XsoItem as Contact; if (string.IsNullOrEmpty(stringData)) { contact.EmailAddresses.Remove(this.emailIndex); return; } Participant participant = contact.EmailAddresses[this.emailIndex]; string text = null; string text2 = null; if (participant != null && !string.IsNullOrEmpty(participant.EmailAddress)) { text2 = EmailAddressConverter.LookupEmailAddressString(participant, contact.Session.MailboxOwner); text = XsoEmailProperty.GetFullEmailString(participant.DisplayName, text2); AirSyncDiagnostics.TraceDebug <string, string, string>(ExTraceGlobals.XsoTracer, this, "XSOEmailProperty convertedSmtpAddress :{0}, currentEmail:{1}, RoutingType:{2}", text2, text, participant.RoutingType); if (participant.RoutingType == "EX" && text2 == participant.EmailAddress) { text2 = SmtpProxyAddress.EncapsulateAddress("EX", participant.EmailAddress, SendMailBase.DefaultDomain); text = XsoEmailProperty.GetFullEmailString(participant.EmailAddress, text2); } } if (stringData != text && stringData != text2) { contact.EmailAddresses.Remove(this.emailIndex); contact.EmailAddresses.Add(this.emailIndex, EmailAddressConverter.CreateParticipant(stringData)); } }
internal static bool Decode(ref string addressType, ref string address, string imceaResolvableDomain) { if (imceaResolvableDomain == null) { return(false); } int num = ImceaAddress.FindImceaDashPosition(address); if (num <= "IMCEA".Length) { return(false); } string text = address.Substring("IMCEA".Length, num - "IMCEA".Length); int num2 = address.LastIndexOf('@'); if (num2 < 0 || num2 == address.Length - 1) { return(false); } string strA = address.Substring(num2 + 1, address.Length - num2 - 1); if (string.Compare(strA, imceaResolvableDomain, StringComparison.OrdinalIgnoreCase) != 0) { return(false); } ProxyAddress proxyAddress = null; if (!SmtpProxyAddress.TryDeencapsulate(address, out proxyAddress)) { return(false); } addressType = text.ToUpper(); address = proxyAddress.AddressString; return(true); }
public static void ValidateExternalEmailAddress(ADContact contact, IConfigurationSession configurationSession, Task.ErrorLoggerDelegate writeError, ProvisioningCache provisioningCache) { if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.ValidateExternalEmailAddressInAcceptedDomain.Enabled) { SmtpProxyAddress smtpProxyAddress = contact.ExternalEmailAddress as SmtpProxyAddress; if (smtpProxyAddress == null) { writeError(new RecipientTaskException(Strings.ErrorExternalEmailAddressNotSmtpAddress((contact.ExternalEmailAddress == null) ? "$null" : contact.ExternalEmailAddress.ToString())), ExchangeErrorCategory.Client, contact.Identity); return; } if (RecipientTaskHelper.SMTPAddressCheckWithAcceptedDomain(configurationSession, contact.OrganizationId, writeError, provisioningCache)) { string domain = new SmtpAddress(smtpProxyAddress.SmtpAddress).Domain; if (RecipientTaskHelper.IsAcceptedDomain(configurationSession, contact.OrganizationId, domain, provisioningCache)) { writeError(new RecipientTaskException(Strings.ErrorIsAcceptedDomain(domain)), ExchangeErrorCategory.Client, null); } } contact.EmailAddressPolicyEnabled = false; if (contact.PrimarySmtpAddress == SmtpAddress.Empty) { contact.PrimarySmtpAddress = new SmtpAddress(smtpProxyAddress.SmtpAddress); } } }
protected ADObjectId ResolveMailboxDatabase(ADRawEntry activeDirectoryRawEntry) { if (activeDirectoryRawEntry == null) { throw new ArgumentNullException("activeDirectoryRawEntry"); } SmtpProxyAddress smtpProxyAddress = (SmtpProxyAddress)activeDirectoryRawEntry[ADRecipientSchema.ExternalEmailAddress]; if (smtpProxyAddress != null) { OrganizationId key = (OrganizationId)activeDirectoryRawEntry[ADObjectSchema.OrganizationId]; OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(key); if (!((SmtpAddress)smtpProxyAddress).IsValidAddress) { ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: ExternalEmailAddress configured is invalid."); } else { OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(((SmtpAddress)smtpProxyAddress).Domain); if (organizationRelationship != null && organizationRelationship.TargetOwaURL != null) { string absoluteUri = organizationRelationship.TargetOwaURL.AbsoluteUri; ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: Stop processing and redirect to {0}.", absoluteUri); base.Logger.AppendGenericInfo("ExternalRedir", absoluteUri); throw new ServerSideTransferException(absoluteUri, LegacyRedirectTypeOptions.Manual); } ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: Unable to find OrganizationRelationShip or its TargetOwaUrl is not configured."); base.Logger.AppendGenericInfo("ExternalRedir", "Org-Relationship or targetOwaUrl not found."); } } return(null); }
private static User CreateUserFromMailboxInfo(MailboxInfo mailbox) { SmtpAddress primarySmtpAddress; if (mailbox.IsArchive) { string text = (mailbox.ArchiveDomain != null) ? mailbox.ArchiveDomain.Domain : null; if (text == null) { text = mailbox.PrimarySmtpAddress.Domain; } primarySmtpAddress = new SmtpAddress(SmtpProxyAddress.EncapsulateExchangeGuid(text, mailbox.ArchiveGuid)); } else if (mailbox.ExternalEmailAddress != null) { primarySmtpAddress = new SmtpAddress(mailbox.ExternalEmailAddress.AddressString); } else { primarySmtpAddress = mailbox.PrimarySmtpAddress; } return(new User { Mailbox = primarySmtpAddress.ToString() }); }
private static string[] GetSmtpAddressCache(ADRawEntry person) { List<string> list = new List<string>(1); object obj; if (person.TryGetValueWithoutDefault(ADRecipientSchema.EmailAddresses, out obj)) { ProxyAddressCollection proxyAddressCollection = obj as ProxyAddressCollection; if (proxyAddressCollection != null) { foreach (ProxyAddress proxyAddress in proxyAddressCollection) { SmtpProxyAddress smtpProxyAddress = proxyAddress as SmtpProxyAddress; if (smtpProxyAddress != null) { string text = smtpProxyAddress.ToString(); if (!string.IsNullOrEmpty(text)) { list.Add(text); } } } } } return list.ToArray(); }
private static HashSet<string> GetEmailAddresses(ADRawEntry person) { HashSet<string> hashSet = new HashSet<string>(); object obj; if (person.TryGetValueWithoutDefault(ADRecipientSchema.EmailAddresses, out obj)) { ProxyAddressCollection proxyAddressCollection = obj as ProxyAddressCollection; if (proxyAddressCollection != null) { foreach (ProxyAddress proxyAddress in proxyAddressCollection) { SmtpProxyAddress smtpProxyAddress = proxyAddress as SmtpProxyAddress; if (smtpProxyAddress != null) { string text = ContactInfoForLinking.CanonicalizeEmailAddress(smtpProxyAddress.SmtpAddress); if (!string.IsNullOrEmpty(text)) { hashSet.Add(text); } } } } } return hashSet; }
private ExchangePrincipal GetExchangePrincipalForRecipient(MailRecipient recipient, DeliverableItem item, ICollection <CultureInfo> recipientLanguages, bool useCompletePrincipal) { ADSessionSettings adsessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(recipient.MailItemScopeOrganizationId); Guid databaseGuid = this.context.MbxTransportMailItem.DatabaseGuid; ExchangePrincipal exchangePrincipal; if (this.IsPublicFolderRecipient(item)) { ADObjectId value = recipient.ExtendedProperties.GetValue <ADObjectId>("Microsoft.Exchange.Transport.DirectoryData.ContentMailbox", null); StoreObjectId storeObjectId = null; if (value == null || !StoreObjectId.TryParseFromHexEntryId(recipient.ExtendedProperties.GetValue <string>("Microsoft.Exchange.Transport.DirectoryData.EntryId", null), out storeObjectId)) { throw new SmtpResponseException(AckReason.UnableToDetermineTargetPublicFolderMailbox, MessageAction.Reroute); } this.deliverToFolder = storeObjectId; try { exchangePrincipal = ExchangePrincipal.FromDirectoryObjectId(DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, adsessionSettings, 830, "GetExchangePrincipalForRecipient", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\DeliveryItem.cs"), value, RemotingOptions.LocalConnectionsOnly); goto IL_14C; } catch (Microsoft.Exchange.Data.Storage.ObjectNotFoundException) { throw new SmtpResponseException(AckReason.PublicFolderMailboxNotFound, MessageAction.Reroute); } } MailboxItem mailboxItem = item as MailboxItem; if (mailboxItem == null) { throw new InvalidOperationException("Delivery to PFDBs is not supported in E15"); } if (!useCompletePrincipal) { string legacyExchangeDN; if (!recipient.ExtendedProperties.TryGetValue <string>("Microsoft.Exchange.Transport.MailRecipient.DisplayName", out legacyExchangeDN)) { legacyExchangeDN = mailboxItem.LegacyExchangeDN; } exchangePrincipal = ExchangePrincipal.FromMailboxData(legacyExchangeDN, adsessionSettings, databaseGuid, mailboxItem.MailboxGuid, mailboxItem.LegacyExchangeDN, recipient.Email.ToString(), recipientLanguages ?? new MultiValuedProperty <CultureInfo>(), true, mailboxItem.RecipientType, mailboxItem.RecipientTypeDetails.GetValueOrDefault()); } else { ProxyAddress proxyAddress = new SmtpProxyAddress((string)recipient.Email, true); exchangePrincipal = ExchangePrincipal.FromProxyAddress(adsessionSettings, proxyAddress.ToString()); } IL_14C: if (exchangePrincipal.MailboxInfo.IsRemote) { throw new SmtpResponseException(AckReason.RecipientMailboxIsRemote, MessageAction.Reroute); } if (exchangePrincipal.MailboxInfo.Location == MailboxDatabaseLocation.Unknown) { throw new SmtpResponseException(AckReason.RecipientMailboxLocationInfoNotAvailable, MessageAction.Reroute); } return(exchangePrincipal); }
// Token: 0x06000223 RID: 547 RVA: 0x0000CD1C File Offset: 0x0000AF1C private static string SafeGetEmailDomainFromADUser(ADRecipient user) { SmtpProxyAddress smtpProxyAddress = user.ExternalEmailAddress as SmtpProxyAddress; if (!(smtpProxyAddress != null)) { return(null); } return(((SmtpAddress)smtpProxyAddress).Domain); }
public User FindBySmtpAddress(SmtpAddress smtpAddress, IRoutingDiagnostics diagnostics) { return(this.Execute <User>(delegate { SmtpProxyAddress proxyAddress = new SmtpProxyAddress(smtpAddress.ToString(), true); ADSessionSettings sessionSettings = ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(smtpAddress.Domain); IRecipientSession tenantOrRootOrgRecipientSession = this.directorySessionFactoryInstance.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 88, "FindBySmtpAddress", "f:\\15.00.1497\\sources\\dev\\cafe\\src\\Routing\\Providers\\ActiveDirectoryUserProvider.cs"); ADRawEntry rawEntry = ActiveDirectoryUserProvider.FindByProxyAddress(proxyAddress, tenantOrRootOrgRecipientSession, diagnostics); return ActiveDirectoryUserProvider.CreateUserFromAdRawEntry(rawEntry); }, "FindBySmtpAddress failed")); }
private SmtpProxyAddress[] CreateSmtpProxyAddressArray() { SmtpProxyAddress[] array = new SmtpProxyAddress[this.resultDictionary.Count]; int num = 0; foreach (ADQueryResult adqueryResult in this.resultDictionary.Values) { array[num] = adqueryResult.UserResultMapping.SmtpProxyAddress; num++; } return(array); }
internal static RecipientData CreateAsContact(EmailAddress emailAddress) { RecipientData recipientData = new RecipientData(emailAddress); SmtpProxyAddress value = new SmtpProxyAddress(emailAddress.Address, true); recipientData.propertyMap = new Dictionary <PropertyDefinition, object>(); recipientData.propertyMap[ADRecipientSchema.RecipientType] = RecipientType.MailUser; recipientData.propertyMap[ADRecipientSchema.ExternalEmailAddress] = value; SmtpAddress smtpAddress = new SmtpAddress(emailAddress.Address); recipientData.propertyMap[ADRecipientSchema.PrimarySmtpAddress] = smtpAddress; return(recipientData); }
internal static bool IsRetentionPolicyEnabled(ADRecipientCache <TransportMiniRecipient> cache, RoutingAddress address) { ProxyAddress proxyAddress = new SmtpProxyAddress((string)address, true); TransportMiniRecipient data = cache.FindAndCacheRecipient(proxyAddress).Data; if (data == null) { return(false); } ElcMailboxFlags elcMailboxFlags = data.ElcMailboxFlags; ADObjectId elcPolicyTemplate = data.ElcPolicyTemplate; return(((elcMailboxFlags & ElcMailboxFlags.ElcV2) != ElcMailboxFlags.None && elcPolicyTemplate != null) || ((elcMailboxFlags & ElcMailboxFlags.ShouldUseDefaultRetentionPolicy) != ElcMailboxFlags.None && elcPolicyTemplate == null)); }
internal IEnumerable <string> Resolve(IEnumerable <string> addresses, IRecipientSession session) { if (addresses == null) { return(null); } int num = 0; List <ProxyAddress> list = new List <ProxyAddress>(); foreach (string text in addresses) { num++; if (!this.lookupCache.ContainsKey(text)) { list.Add(ProxyAddress.Parse(text)); this.lookupCache[text] = null; } } this.AddressesLookedUp = list.Count; if (list.Count > 0) { ProxyAddress[] array = list.ToArray(); Result <ADRawEntry>[] array2 = session.FindByProxyAddresses(array, BulkRecipientLookupCache.displayNameProperty); for (int i = 0; i < array.Length; i++) { ADRawEntry data = array2[i].Data; string addressString = array[i].AddressString; string value = null; if (data != null) { value = (data[ADRecipientSchema.DisplayName] as string); } if (string.IsNullOrEmpty(value)) { ProxyAddress proxyAddress; if (SmtpProxyAddress.TryDeencapsulate(array[i].AddressString, out proxyAddress) && !string.IsNullOrEmpty(proxyAddress.AddressString)) { value = proxyAddress.AddressString; } else { value = array[i].AddressString; } } this.lookupCache[addressString] = value; } } return(from address in addresses select this.lookupCache[address]); }
// Token: 0x06000172 RID: 370 RVA: 0x0000A128 File Offset: 0x00008328 private static SmtpAddress GetDiscoveryHolds(DiscoverySearchDataProvider dataProvider, Dictionary <string, MailboxDiscoverySearch> discoveryHolds) { SmtpAddress smtpAddress = SmtpAddress.Empty; ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(ADSystemConfigurationSession.GetRootOrgContainerIdForLocalForest(), OrganizationId.ForestWideOrgId, null, false); IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(true, ConsistencyMode.IgnoreInvalid, sessionSettings, 324, "GetDiscoveryHolds", "f:\\15.00.1497\\sources\\dev\\MailboxAssistants\\src\\assistants\\elc\\DiscoveryHoldSynchronizer.cs"); foreach (MailboxDiscoverySearch mailboxDiscoverySearch in dataProvider.GetAll <MailboxDiscoverySearch>()) { if (mailboxDiscoverySearch.InPlaceHoldEnabled) { discoveryHolds.Add(mailboxDiscoverySearch.InPlaceHoldIdentity, mailboxDiscoverySearch); if (smtpAddress == SmtpAddress.Empty) { Result <ADRawEntry>[] first = tenantOrRootOrgRecipientSession.FindByLegacyExchangeDNs(mailboxDiscoverySearch.Sources.ToArray(), new ADPropertyDefinition[] { ADRecipientSchema.RecipientType, ADRecipientSchema.RecipientTypeDetails, ADUserSchema.ArchiveDomain, ADUserSchema.ArchiveGuid, ADRecipientSchema.RawExternalEmailAddress, ADUserSchema.ArchiveStatus }); foreach (ADRawEntry adrawEntry in from x in first select x.Data) { if (adrawEntry != null) { RecipientType recipientType = (RecipientType)adrawEntry[ADRecipientSchema.RecipientType]; RecipientTypeDetails recipientTypeDetails = (RecipientTypeDetails)adrawEntry[ADRecipientSchema.RecipientTypeDetails]; SmtpDomain smtpDomain = (SmtpDomain)adrawEntry[ADUserSchema.ArchiveDomain]; ArchiveStatusFlags archiveStatusFlags = (ArchiveStatusFlags)adrawEntry[ADUserSchema.ArchiveStatus]; if (RemoteMailbox.IsRemoteMailbox(recipientTypeDetails)) { smtpAddress = new SmtpAddress(((ProxyAddress)adrawEntry[ADRecipientSchema.RawExternalEmailAddress]).AddressString); } else if (recipientType == RecipientType.UserMailbox && smtpDomain != null && !string.IsNullOrEmpty(smtpDomain.Domain) && (archiveStatusFlags & ArchiveStatusFlags.Active) == ArchiveStatusFlags.Active) { Guid guid = (Guid)adrawEntry[ADUserSchema.ArchiveGuid]; if (guid != Guid.Empty) { smtpAddress = new SmtpAddress(SmtpProxyAddress.EncapsulateExchangeGuid(smtpDomain.Domain, guid)); } } } } } } } return(smtpAddress); }
// Token: 0x06000302 RID: 770 RVA: 0x000100E8 File Offset: 0x0000E2E8 private string GetRedirectAddressForUserHasNoMailbox(ActiveSyncMiniRecipient activesyncMiniRecipient) { string easEndpoint = null; if (!VariantConfiguration.InvariantNoFlightingSnapshot.ActiveSync.RedirectForOnBoarding.Enabled) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "The hybrid on boarding redirect feature is only for OnPrem servers."); return(null); } if (this.context.CommandType != CommandType.Options && this.context.AirSyncVersion < GlobalSettings.MinRedirectProtocolVersion) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "The protocol version is less than 14.0 that doesn't support 451 redirect protocol call."); return(null); } AirSyncDiagnostics.FaultInjectionPoint(3414568253U, delegate { if (activesyncMiniRecipient != null && activesyncMiniRecipient.ExternalEmailAddress != null) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Try to figure out eas endpoint for user: {0}.", activesyncMiniRecipient.ExternalEmailAddress.AddressString); this.context.ProtocolLogger.SetValue(ProtocolLoggerData.RedirectTo, "TryToFigureOutEasEndpoint"); SmtpProxyAddress smtpProxyAddress = activesyncMiniRecipient.ExternalEmailAddress as SmtpProxyAddress; if (smtpProxyAddress != null && !string.IsNullOrEmpty(smtpProxyAddress.AddressString)) { OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(activesyncMiniRecipient.OrganizationId); string domain = ((SmtpAddress)smtpProxyAddress).Domain; OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(domain); if (organizationRelationship != null) { Uri targetOwaURL = organizationRelationship.TargetOwaURL; easEndpoint = this.TransferTargetOwaUrlToEasEndpoint(targetOwaURL); AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "Redirect to EASEndpoint : {0}.", easEndpoint); this.context.ProtocolLogger.AppendValue(ProtocolLoggerData.RedirectTo, easEndpoint); return; } AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, "OrganizationRelationShip is null for the domain {0}", domain); return; } else { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "External email address is null"); } } }, delegate { Uri targetOwaUri = new Uri("http://outlook.com/owa"); easEndpoint = this.TransferTargetOwaUrlToEasEndpoint(targetOwaUri); }); return(easEndpoint); }
public static bool IsMemberOf(RmsClientManagerContext clientContext, string recipientAddress, string groupAddress) { ArgumentValidator.ThrowIfNull("recipientAddress", recipientAddress); ArgumentValidator.ThrowIfNullOrEmpty("groupAddress", groupAddress); if (!ServerManager.instance.isHostingInstance) { throw new InvalidOperationException("Can't call IsMemberOf directly as ServerManager is NOT allowed to host in current calling process"); } if (!SmtpAddress.IsValidSmtpAddress(recipientAddress)) { ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Error, clientContext, string.Format("recipientAddress {0} is invalid SMTP Address", recipientAddress)); return(false); } if (!RoutingAddress.IsValidAddress(groupAddress)) { ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Error, clientContext, string.Format("groupAddress {0} is invalid SMTP Address", groupAddress)); return(false); } ServerManager.InitializeIfNeeded(); bool result; if (ServerManager.CheckForSpecialRmsOnlineTenantMembershipQuery(recipientAddress, groupAddress, out result)) { return(result); } ADRawEntry adrawEntry = clientContext.ResolveRecipient(recipientAddress); if (adrawEntry == null) { ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Verbose, clientContext, string.Format("Failed to resolve recipientAddress {0} in Active Directory. Treat IsMemberOf for {1} against {2} as false", recipientAddress, recipientAddress, groupAddress)); return(false); } ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)adrawEntry[ADRecipientSchema.EmailAddresses]; SmtpProxyAddress other = new SmtpProxyAddress(groupAddress, true); foreach (ProxyAddress proxyAddress in proxyAddressCollection) { if (proxyAddress.Equals(other)) { ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Success, clientContext, string.Format("IsMemberOf return true as proxyAddress {0} is the same is groupAddress {1}", recipientAddress, groupAddress)); return(true); } } RoutingAddress groupKey = new RoutingAddress(groupAddress); bool result2 = ServerManager.instance.isMemberOfResolver.IsMemberOf(clientContext.RecipientSession, adrawEntry.Id, groupKey); ServerManagerLog.LogEvent(ServerManagerLog.Subcomponent.DirectoryServiceProvider, ServerManagerLog.EventType.Success, clientContext, string.Format("IsMemberOf return {0} for proxyAddress {1} against groupAddress {2}", result2.ToString(CultureInfo.InvariantCulture), recipientAddress, groupAddress)); return(result2); }
// Token: 0x06000778 RID: 1912 RVA: 0x0001D120 File Offset: 0x0001B320 internal static bool TryGetExchangeGuidFromEmailAddress(string emailAddress, out Guid exchangeGuid) { exchangeGuid = Guid.Empty; if (string.IsNullOrEmpty(emailAddress) || !SmtpAddress.IsValidSmtpAddress(emailAddress)) { return(false); } if (SmtpProxyAddress.TryDeencapsulateExchangeGuid(emailAddress, out exchangeGuid)) { return(true); } SmtpAddress smtpAddress = new SmtpAddress(emailAddress); return(!string.IsNullOrEmpty(smtpAddress.Local) && Guid.TryParse(smtpAddress.Local, out exchangeGuid)); }
private SmtpAddress?GetRemoteIdentity(IGenericADUser adUser, bool isArchive) { if (isArchive) { if (adUser.ArchiveDomain != null && (adUser.ArchiveStatus & ArchiveStatusFlags.Active) == ArchiveStatusFlags.Active) { return(new SmtpAddress?(new SmtpAddress(SmtpProxyAddress.EncapsulateExchangeGuid(adUser.ArchiveDomain.Domain, adUser.ArchiveGuid)))); } } else if (adUser.ExternalEmailAddress.Prefix == ProxyAddressPrefix.Smtp && SmtpAddress.IsValidSmtpAddress(adUser.ExternalEmailAddress.AddressString)) { return(new SmtpAddress?(new SmtpAddress(adUser.ExternalEmailAddress.AddressString))); } return(null); }
private string EnsureGroupIsInDirectoryCache(GroupMailbox group) { IRecipientSession tenantOrRootRecipientReadOnlySession = DirectorySessionFactory.Default.GetTenantOrRootRecipientReadOnlySession(base.ADSession, group.OriginatingServer, 350, "EnsureGroupIsInDirectoryCache", "f:\\15.00.1497\\sources\\dev\\Management\\src\\FederatedDirectory\\CreateUnifiedGroupTask.cs"); ProxyAddress proxyAddress = new SmtpProxyAddress(group.PrimarySmtpAddress.ToString(), true); OWAMiniRecipient owaminiRecipient = tenantOrRootRecipientReadOnlySession.FindMiniRecipientByProxyAddress <OWAMiniRecipient>(proxyAddress, OWAMiniRecipientSchema.AdditionalProperties); string text = (owaminiRecipient != null) ? (owaminiRecipient.IsCached ? "ReadFromCache" : "ReadFromDc") : "NotFound"; UnifiedGroupsTask.Tracer.TraceDebug((long)this.GetHashCode(), "ActivityId={0}. CreateUnifiedGroupTask.EnsureGroupIsInDirectoryCache: ProxyAddress={1}, DomainController={2}, Result={3}", new object[] { base.ActivityId, proxyAddress, group.OriginatingServer, text }); return(text); }
public static string Encode(string type, string address, string domain) { Util.ThrowOnNullArgument(type, "type"); Util.ThrowOnNullArgument(address, "address"); if (address.StartsWith(type + ':', StringComparison.OrdinalIgnoreCase)) { address = address.Substring(type.Length + 1).Trim(); } SmtpProxyAddress smtpProxyAddress; if (SmtpProxyAddress.TryEncapsulate(type, address, domain, out smtpProxyAddress)) { return(smtpProxyAddress.SmtpAddress); } return(null); }
public static string[] GetAllEmailAddresses(string emailAddress, OrganizationId organizationId) { if (string.IsNullOrEmpty(emailAddress)) { throw new ArgumentNullException("emailAddress"); } if (organizationId == null) { throw new ArgumentNullException("organizationId"); } if (emailAddress.IndexOf('@') > 0) { if (!SmtpAddress.IsValidSmtpAddress(emailAddress)) { throw new ArgumentException(string.Format("emailAddress:{0} is not a valid ProxyAddress", emailAddress)); } ProxyAddress proxyAddress = new SmtpProxyAddress(emailAddress, false); IRecipientSession recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(organizationId), 345, "GetAllEmailAddresses", "f:\\15.00.1497\\sources\\dev\\clients\\src\\Owa2\\Server\\Core\\PolicyTips\\ADUtils.cs"); ADRawEntry lookupResult = null; ADNotificationAdapter.RunADOperation(delegate() { lookupResult = recipientSession.FindByProxyAddress(proxyAddress, ADUtils.PropertiesToGet); }); if (lookupResult != null) { ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)lookupResult[ADRecipientSchema.EmailAddresses]; if (proxyAddressCollection != null && proxyAddressCollection.Count > 0) { string[] array = new string[proxyAddressCollection.Count]; int num = 0; foreach (ProxyAddress proxyAddress2 in proxyAddressCollection) { array[num++] = proxyAddress2.AddressString; } return(array); } } } return(new string[] { emailAddress }); }
internal ValidRecipient(string smtpAddress, ADRecipient adRecipient) { Util.ThrowOnNullOrEmptyArgument(smtpAddress, "smtpAddress"); if (!Microsoft.Exchange.Data.SmtpAddress.IsValidSmtpAddress(smtpAddress)) { throw new ArgumentOutOfRangeException(ServerStrings.InvalidSmtpAddress(smtpAddress)); } this.SmtpAddress = smtpAddress; this.ADRecipient = adRecipient; SmtpProxyAddress smtpProxyAddress = (adRecipient != null) ? (adRecipient.ExternalEmailAddress as SmtpProxyAddress) : null; if (smtpProxyAddress != null) { ExTraceGlobals.SharingTracer.TraceDebug <ADObjectId, SmtpProxyAddress>((long)this.GetHashCode(), "{0}: using ExternalEmailAddress as SmtpAddress: {1}", adRecipient.Id, smtpProxyAddress); this.SmtpAddressForEncryption = smtpProxyAddress.SmtpAddress; return; } this.SmtpAddressForEncryption = smtpAddress; }
// Token: 0x060005CB RID: 1483 RVA: 0x000202C4 File Offset: 0x0001E4C4 protected ADObjectId ResolveMailboxDatabase(ADRawEntry activeDirectoryRawEntry) { if (activeDirectoryRawEntry == null) { throw new ArgumentNullException("activeDirectoryRawEntry"); } SmtpProxyAddress smtpProxyAddress = (SmtpProxyAddress)activeDirectoryRawEntry[ADRecipientSchema.ExternalEmailAddress]; if (smtpProxyAddress != null) { OrganizationId organizationId = (OrganizationId)activeDirectoryRawEntry[ADObjectSchema.OrganizationId]; OrganizationIdCacheValue organizationIdCacheValue = OrganizationIdCache.Singleton.Get(organizationId); SmtpAddress smtpAddress = (SmtpAddress)smtpProxyAddress; if (!smtpAddress.IsValidAddress) { if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: ExternalEmailAddress configured is invalid."); } } else { OrganizationRelationship organizationRelationship = organizationIdCacheValue.GetOrganizationRelationship(((SmtpAddress)smtpProxyAddress).Domain); if (organizationRelationship != null && organizationRelationship.TargetOwaURL != null) { string absoluteUri = organizationRelationship.TargetOwaURL.AbsoluteUri; if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug <string>((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: Stop processing and redirect to {0}.", absoluteUri); } base.Logger.AppendGenericInfo("ExternalRedir", absoluteUri); throw new HttpException(302, this.GetCrossPremiseRedirectUrl(smtpAddress.Domain, organizationId.ToExternalDirectoryOrganizationId(), smtpProxyAddress.SmtpAddress)); } if (ExTraceGlobals.VerboseTracer.IsTraceEnabled(1)) { ExTraceGlobals.VerboseTracer.TraceDebug((long)this.GetHashCode(), "[OwaProxyRequestHandler::ResolveMailboxDatabase]: Unable to find OrganizationRelationShip or its TargetOwaUrl is not configured."); } base.Logger.AppendGenericInfo("ExternalRedir", "Org-Relationship or targetOwaUrl not found."); } } return(null); }
// Token: 0x06000C20 RID: 3104 RVA: 0x00053828 File Offset: 0x00051A28 private static void ProcessRecipients(MessageItem mailToMessage, string value, RecipientItemType recipientItemType) { if (string.IsNullOrEmpty(value)) { return; } value = HttpUtility.UrlDecode(value); Participant participant; bool flag = Participant.TryParse(value, out participant); if (flag) { ProxyAddress proxyAddress; if (ImceaAddress.IsImceaAddress(participant.EmailAddress) && SmtpProxyAddress.TryDeencapsulate(participant.EmailAddress, out proxyAddress)) { participant = new Participant((participant.DisplayName != participant.EmailAddress) ? participant.DisplayName : proxyAddress.AddressString, proxyAddress.AddressString, proxyAddress.PrefixString); } mailToMessage.Recipients.Add(participant, recipientItemType); } }
internal static ADUser GetADUser(MailboxSession session, bool readOnly, out IRecipientSession recipSession) { recipSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(readOnly, ConsistencyMode.FullyConsistent, session.MailboxOwner.MailboxInfo.OrganizationId.ToADSessionSettings(), 43, "GetADUser", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdReader.cs"); ADRecipient adrecipient = null; string text = session.MailboxOwner.MailboxInfo.PrimarySmtpAddress.ToString(); try { if (session.MailboxOwner.MailboxInfo.MailboxGuid != Guid.Empty) { adrecipient = recipSession.FindByExchangeGuidIncludingArchive(session.MailboxOwner.MailboxInfo.MailboxGuid); } else if (SmtpAddress.IsValidSmtpAddress(text)) { SmtpProxyAddress proxyAddress = new SmtpProxyAddress(text, true); adrecipient = recipSession.FindByProxyAddress(proxyAddress); } else { AdReader.Tracer.TraceDebug <string>(0L, "Mailbox '{0}' does not have a valid smtp address.", text); } } catch (DataValidationException) { AdReader.Tracer.TraceError <string>(0L, "AD object for '{0}' has a data validation issue.", text); return(null); } if (adrecipient == null) { AdReader.Tracer.TraceDebug <string>(0L, "Mailbox '{0}' does not have a user associated with it.", text); return(null); } ADUser aduser = adrecipient as ADUser; if (aduser == null) { AdReader.Tracer.TraceDebug <string>(0L, "'{0}': Is not an ADUser.", text); return(null); } return(aduser); }