private void SetMembers(IRecipientSession adRecipientSession, IADDistributionList distributionList, GetGroupResponse response) { ADGroup adgroup = distributionList as ADGroup; if (adgroup == null) { throw new InvalidOperationException("AD DL object that is not dynamic DL must be ADGroup class"); } if (adgroup.HiddenGroupMembershipEnabled) { this.WriteDebugTrace("HiddenGroupMembershipEnabled is true - Members information is not loaded"); return; } if (this.paging.Offset < 0 || distributionList.Members.Count <= this.paging.Offset) { this.WriteDebugTrace(string.Format("Provided offset is out of range - members count is {0}, offset is {1}.", distributionList.Members.Count, this.paging.Offset)); return; } QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MemberOfGroup, adgroup.Id); SortBy sortBy = new SortBy(ADRecipientSchema.DisplayName, SortOrder.Ascending); ADPagedReader <ADRawEntry> adpagedReader = adRecipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, filter, sortBy, 10000, GetGroupCommand.groupItemsProperties); using (IEnumerator <ADRawEntry> enumerator = adpagedReader.GetEnumerator()) { List <Persona> list = new List <Persona>(); int num = 0; int num2 = this.paging.Offset + this.paging.MaxRows; while (enumerator.MoveNext()) { if (num < this.paging.Offset) { num++; } else { if (num == num2) { break; } Persona personaFromADObject = GetGroupCommand.GetPersonaFromADObject(enumerator.Current); if (personaFromADObject != null) { list.Add(personaFromADObject); num++; } else { response.MembersCount--; } } } response.Members = list.ToArray(); this.WriteDebugTrace("DL members count loaded in the response is " + response.Members.Length); } }
private void PurgeInvalidAssignmentsFromRoleGroup(RoleGroupRoleMapping rgMapping, ADGroup roleGroup, List <ExchangeRole> topCannedRoles) { TaskLogger.LogEnter(); if (!InstallCannedRbacRoleAssignments.MonitoredDCOnlyRoleGroups.Contains(rgMapping.RoleGroup)) { return; } List <string> list = new List <string>(rgMapping.Assignments.Length * 2); RoleAssignmentDefinition[] assignments = rgMapping.Assignments; for (int i = 0; i < assignments.Length; i++) { RoleAssignmentDefinition assignmentDefinition = assignments[i]; List <ExchangeRole> list2 = topCannedRoles.FindAll((ExchangeRole x) => x.RoleType.Equals(assignmentDefinition.RoleType)); if (list2 != null) { foreach (ExchangeRole exchangeRole in list2) { list.Add(exchangeRole.DistinguishedName); list.Add(exchangeRole.Id.GetChildId(RoleDefinition.GetDCSafeNameForRole(exchangeRole.Name)).DistinguishedName); } } } ADPagedReader <ExchangeRoleAssignment> adpagedReader = this.configurationSession.FindPaged <ExchangeRoleAssignment>(base.OrgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer), QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleAssignmentSchema.User, roleGroup.Id), null, 0); using (IEnumerator <ExchangeRoleAssignment> enumerator2 = adpagedReader.GetEnumerator()) { while (enumerator2.MoveNext()) { ExchangeRoleAssignment roleAssignment = enumerator2.Current; if (!list.Contains(roleAssignment.Role.DistinguishedName, StringComparer.OrdinalIgnoreCase)) { if (topCannedRoles.Find((ExchangeRole x) => x.Name.Equals(roleAssignment.Role.Name, StringComparison.OrdinalIgnoreCase) && x.RoleType.Equals(RoleType.UnScoped)) == null) { ExchangeRole exchangeRole2 = this.configurationSession.Read <ExchangeRole>(roleAssignment.Role); if (exchangeRole2 != null && !exchangeRole2.RoleType.Equals(RoleType.UnScoped)) { this.RemoveRoleAssignment(roleAssignment); } } } } } TaskLogger.LogExit(); }
internal static void CheckModerationInMixedEnvironment(ADRecipient recipient, Task.TaskWarningLoggingDelegate warningLogger, LocalizedString warningText) { if (!recipient.ModerationEnabled || !recipient.IsModified(ADRecipientSchema.ModerationEnabled)) { return; } ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 103, "CheckModerationInMixedEnvironment", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\RecipientTasks\\DistributionList\\DistributionGroupTaskHelper.cs"); ADPagedReader <MiniServer> adpagedReader = topologyConfigurationSession.FindPagedMiniServer(null, QueryScope.SubTree, DistributionGroupTaskHelper.filter, null, 1, DistributionGroupTaskHelper.ExchangeVersionProperties); using (IEnumerator <MiniServer> enumerator = adpagedReader.GetEnumerator()) { if (enumerator.MoveNext()) { MiniServer miniServer = enumerator.Current; warningLogger(warningText); } } }
protected override void InternalValidate() { base.InternalValidate(); if (this.DataObject.FederatedTenant) { if (this.DataObject.IsChanged(SyncOrganizationSchema.DisableWindowsLiveID) || this.DataObject.IsChanged(SyncOrganizationSchema.PasswordFilePath) || this.DataObject.IsChanged(SyncOrganizationSchema.ResetPasswordOnNextLogon)) { base.WriteError(new ArgumentException(Strings.ErrorParameterInvalidForFederatedTenant(this.DataObject.Identity.ToString())), (ErrorCategory)1000, null); } } else if (this.DataObject.IsChanged(SyncOrganizationSchema.FederatedIdentitySourceADAttribute)) { base.WriteError(new ArgumentException(Strings.ErrorParameterInvalidForManagedTenant(this.DataObject.Identity.ToString())), (ErrorCategory)1000, null); } if (this.DataObject.IsChanged(SyncOrganizationSchema.ProvisioningDomain)) { IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession; ADPagedReader <AcceptedDomain> adpagedReader = configurationSession.FindPaged <AcceptedDomain>(null, QueryScope.SubTree, null, null, 0); bool flag = false; using (IEnumerator <AcceptedDomain> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext() && !flag) { if (enumerator.Current.DomainName.Match(this.DataObject.ProvisioningDomain.Address) >= 0) { flag = true; } } } if (!flag) { base.WriteError(new ArgumentException(Strings.ErrorProvisioningDomainNotMatchAcceptedDomain(this.DataObject.ProvisioningDomain.Address, this.DataObject.Identity.ToString())), (ErrorCategory)1000, null); } } if (this.DataObject.IsChanged(SyncOrganizationSchema.FederatedIdentitySourceADAttribute) && !string.Equals(this.DataObject.FederatedIdentitySourceADAttribute, "objectGuid", StringComparison.OrdinalIgnoreCase)) { this.WriteWarning(Strings.WarningChangeOfFederatedIdentitySourceADAttribute("objectGuid")); } }
private void GetRecipientInformation(string proxyAddress, out ADRawEntry adRecipientEntry, out AcceptedDomain defaultDomain) { adRecipientEntry = null; defaultDomain = null; ComparisonFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.EmailAddresses, proxyAddress.ToString()); ADPagedReader <ADRecipient> adpagedReader = this.recipSession.FindPaged(null, QueryScope.SubTree, filter, null, 0); using (IEnumerator <ADRecipient> enumerator = adpagedReader.GetEnumerator()) { if (enumerator.MoveNext()) { adRecipientEntry = enumerator.Current; OrganizationId organizationId = ((ADRecipient)adRecipientEntry).OrganizationId; IConfigurationSession configurationSession = this.CreateConfigurationSession(organizationId); defaultDomain = configurationSession.GetDefaultAcceptedDomain(); if (defaultDomain == null) { throw new DataValidationException(new ObjectValidationError(Strings.ErrorNoDefaultAcceptedDomainFound(organizationId.ToString()), null, null)); } } } }
private MultiValuedProperty <string> AcceptedDomainNamesGetter(ADOrganizationConfig org) { MultiValuedProperty <string> multiValuedProperty = new MultiValuedProperty <string>(); if (!string.IsNullOrEmpty(org.MicrosoftExchangeRecipientPrimarySmtpAddress.Domain)) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.RootOrgOrSingleTenantFromAcceptedDomainAutoDetect(org.MicrosoftExchangeRecipientPrimarySmtpAddress.Domain), 215, "AcceptedDomainNamesGetter", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\GetOrganization.cs"); ADPagedReader <AcceptedDomain> adpagedReader = tenantOrTopologyConfigurationSession.FindPaged <AcceptedDomain>(null, QueryScope.SubTree, null, null, 0); using (IEnumerator <AcceptedDomain> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext()) { AcceptedDomain acceptedDomain = enumerator.Current; multiValuedProperty.Add(acceptedDomain.DomainName.Address); } return(multiValuedProperty); } } if (org.SharedConfigurationInfo == null) { this.WriteWarning(Strings.WarningPrimaryExchangeRecipientNotSet(this.Identity.ToString())); } return(multiValuedProperty); }
private List <SmtpAddress> GetEnabledCrossPremiseAcceptedDomainTargets(IConfigurationSession session) { List <SmtpAddress> list = new List <SmtpAddress>(); QueryFilter filter = new NotFilter(new BitMaskOrFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL)); OrganizationId currentOrganizationId = session.SessionSettings.CurrentOrganizationId; ADObjectId rootId = (OrganizationId.ForestWideOrgId.Equals(currentOrganizationId) || currentOrganizationId == null) ? session.GetOrgContainerId() : currentOrganizationId.ConfigurationUnit; ADPagedReader <AcceptedDomain> adpagedReader = session.FindPaged <AcceptedDomain>(rootId, QueryScope.SubTree, filter, null, 0); using (IEnumerator <AcceptedDomain> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext()) { if (!enumerator.Current.DomainName.IncludeSubDomains && enumerator.Current.IsCoexistenceDomain) { SmtpAddress item = new SmtpAddress("FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042", enumerator.Current.DomainName.Domain); if (item.IsValidAddress) { list.Add(item); } } } } return(list); }
public static SiteMailboxAddressesTemplate GetSiteMailboxAddressesTemplate(IConfigurationSession cfgSession, ProvisioningCache provisioningCache) { if (cfgSession == null) { throw new ArgumentNullException("cfgSession"); } if (provisioningCache == null) { throw new ArgumentNullException("provisioningCache"); } OrganizationId orgId = cfgSession.GetOrgContainer().OrganizationId; return(provisioningCache.TryAddAndGetOrganizationData <SiteMailboxAddressesTemplate>(CannedProvisioningCacheKeys.OrganizationSiteMailboxAddressesTemplate, orgId, delegate() { ADObjectId rootId = orgId.ConfigurationUnit ?? provisioningCache.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.FirstOrgContainerId, () => cfgSession.GetOrgContainerId()); MultiValuedProperty <SmtpDomain> multiValuedProperty = null; ADPagedReader <OnPremisesOrganization> adpagedReader = cfgSession.FindPaged <OnPremisesOrganization>(rootId, QueryScope.SubTree, null, null, 0); using (IEnumerator <OnPremisesOrganization> enumerator = adpagedReader.GetEnumerator()) { if (enumerator.MoveNext()) { OnPremisesOrganization onPremisesOrganization = enumerator.Current; multiValuedProperty = onPremisesOrganization.HybridDomains; } } QueryFilter filter = new NotFilter(new BitMaskAndFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL)); ADPagedReader <AcceptedDomain> adpagedReader2 = cfgSession.FindPaged <AcceptedDomain>(rootId, QueryScope.SubTree, filter, new SortBy(ADObjectSchema.Name, SortOrder.Ascending), 0); bool flag = false; string text = string.Empty; string text2 = string.Empty; string text3 = string.Empty; foreach (AcceptedDomain acceptedDomain in adpagedReader2) { if (acceptedDomain.AuthenticationType != AuthenticationType.Federated && (string.IsNullOrEmpty(text) || acceptedDomain.Default)) { text = acceptedDomain.DomainName.Domain; } if ((multiValuedProperty == null || multiValuedProperty.Count == 0 || multiValuedProperty.Contains(acceptedDomain.DomainName.SmtpDomain)) && (string.IsNullOrEmpty(text2) || acceptedDomain.Default)) { text2 = acceptedDomain.DomainName.Domain; } if (acceptedDomain.IsCoexistenceDomain && string.IsNullOrEmpty(text3)) { text3 = acceptedDomain.DomainName.Domain; } flag = (flag || acceptedDomain.Default); if (flag && !string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text3)) { break; } } SiteMailboxAddressesTemplate siteMailboxAddressesTemplate = new SiteMailboxAddressesTemplate(); siteMailboxAddressesTemplate.UserPrincipalNameDomain = text; if (!string.IsNullOrEmpty(text2)) { siteMailboxAddressesTemplate.AddressTemplates.Add(new SmtpProxyAddressTemplate(string.Format("@{0}", text2), true)); if (!string.IsNullOrEmpty(text3) && !string.Equals(text2, text3, StringComparison.OrdinalIgnoreCase)) { siteMailboxAddressesTemplate.AddressTemplates.Add(new SmtpProxyAddressTemplate(string.Format("@{0}", text3), false)); } } if (!siteMailboxAddressesTemplate.IsValid) { throw new ErrorSiteMailboxCannotLoadAddressTemplateException(); } return siteMailboxAddressesTemplate; })); }
private void StampModeratedTransportExpiry() { byte[] policyTag = null; string text = string.Empty; int retentionPeriod = 2; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(this.mbxTransportMailItem.OrganizationId), 361, "StampModeratedTransportExpiry", "f:\\15.00.1497\\sources\\dev\\MailboxTransport\\src\\MailboxTransportDelivery\\StoreDriver\\agents\\approval\\ApprovalEngine.cs"); ADObjectId descendantId = tenantOrTopologyConfigurationSession.GetOrgContainerId().GetDescendantId(ApprovalApplication.ParentPathInternal); ADObjectId childId = descendantId.GetChildId("ModeratedRecipients"); ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Reading ModeratedRecipient app from {0}", childId); if (childId != null) { ApprovalApplication approvalApplication = tenantOrTopologyConfigurationSession.Read <ApprovalApplication>(childId); if (approvalApplication != null) { ADObjectId elcretentionPolicyTag = approvalApplication.ELCRetentionPolicyTag; ApprovalEngine.diag.TraceDebug <ADObjectId>((long)this.GetHashCode(), "Read ModeratedRecipient, now reading Recipient Policy Tag {0}", elcretentionPolicyTag); RetentionPolicyTag retentionPolicyTag = null; if (elcretentionPolicyTag != null) { retentionPolicyTag = tenantOrTopologyConfigurationSession.Read <RetentionPolicyTag>(elcretentionPolicyTag); } else { IConfigurationSession configurationSession = SharedConfiguration.CreateScopedToSharedConfigADSession(this.mbxTransportMailItem.OrganizationId); if (configurationSession != null) { IList <RetentionPolicyTag> defaultRetentionPolicyTag = ApprovalUtils.GetDefaultRetentionPolicyTag(configurationSession, ApprovalApplicationId.ModeratedRecipient, 1); if (defaultRetentionPolicyTag != null && defaultRetentionPolicyTag.Count > 0) { retentionPolicyTag = defaultRetentionPolicyTag[0]; } } } if (retentionPolicyTag != null) { ADPagedReader <ElcContentSettings> elccontentSettings = retentionPolicyTag.GetELCContentSettings(); using (IEnumerator <ElcContentSettings> enumerator = elccontentSettings.GetEnumerator()) { if (enumerator.MoveNext()) { ElcContentSettings elcContentSettings = enumerator.Current; retentionPeriod = (int)elcContentSettings.AgeLimitForRetention.Value.TotalDays; } } policyTag = retentionPolicyTag.RetentionId.ToByteArray(); } } } }); if (!adoperationResult.Succeeded) { if (adoperationResult.Exception is TransientException) { throw adoperationResult.Exception; } text = adoperationResult.Exception.ToString(); ApprovalEngine.diag.TraceError <string>((long)this.GetHashCode(), "Can't get PolicyTag guid {0}, NDRing.", text); } if (policyTag == null) { ApprovalEngine.diag.TraceError((long)this.GetHashCode(), "PolicyTag not read. NDRing"); string text2 = this.mbxTransportMailItem.OrganizationId.ToString(); StoreDriverDeliveryDiagnostics.LogEvent(MailboxTransportEventLogConstants.Tuple_ApprovalCannotStampExpiry, text2, new object[] { text2, text }); throw new SmtpResponseException(AckReason.ApprovalCannotReadExpiryPolicy); } if (retentionPeriod < 2) { retentionPeriod = 2; } else if (retentionPeriod > 30) { retentionPeriod = 30; } this.messageItem[ItemSchema.RetentionDate] = ExDateTime.UtcNow.AddDays((double)retentionPeriod); this.messageItem[StoreObjectSchema.RetentionPeriod] = retentionPeriod; this.messageItem[StoreObjectSchema.PolicyTag] = policyTag; }
private bool IsAcceptedDomainListEmpty() { ADPagedReader <AcceptedDomain> adpagedReader = this.ConfigurationSession.FindPaged <AcceptedDomain>(base.CurrentOrgContainerId, QueryScope.SubTree, null, null, 1); return(!adpagedReader.GetEnumerator().MoveNext()); }
// Token: 0x060008FA RID: 2298 RVA: 0x0003CBC0 File Offset: 0x0003ADC0 internal void UpdateAllUserSettings(IRecipientSession recipientSession, long cookie, Initiating.ActOnUserSettingsDelegate updateUserSettings, Predicate <ADRawEntry> validate) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADMailboxRecipientSchema.Database, new ADObjectId(base.Context.Guid)), new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.RecipientType, RecipientType.UserMailbox) }); ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, filter, null, 0, new PropertyDefinition[] { ADObjectSchema.Id, ADRecipientSchema.TextMessagingState, IADMailStorageSchema.ExchangeGuid }); using (IEnumerator <ADRawEntry> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext()) { ADRawEntry recipient = enumerator.Current; if (!base.ShouldContinue(cookie)) { break; } if (validate == null || validate(recipient)) { if (this.mailboxTable == null) { this.mailboxTable = base.Context.GetMailboxTable(ClientType.EventBased, new PropertyTagPropertyDefinition[0]); } if (!this.mailboxTable.Exists((MailboxInformation mbxInfo) => mbxInfo.MailboxGuid == (Guid)recipient[IADMailStorageSchema.ExchangeGuid])) { ADUser aduser = recipientSession.FindADUserByObjectId((ADObjectId)recipient[ADObjectSchema.Id]); if (aduser != null) { ExchangePrincipal exchangePrincipal = ExchangePrincipal.FromADUser(aduser, null); MailboxSession mailboxSession = null; try { mailboxSession = base.Context.GetMailbox(exchangePrincipal, ClientType.EventBased, "UpdateAllUserSettings"); if (!base.ShouldContinue(cookie)) { break; } updateUserSettings(mailboxSession, recipientSession, aduser); } catch (NotSupportedException arg) { ExTraceGlobals.AssistantTracer.TraceError <string, NotSupportedException>((long)this.GetHashCode(), "Exception is caught during syncing text messaging settings to AD user object for {0}: {1}", exchangePrincipal.LegacyDn, arg); } catch (Exception ex) { if (!CalendarNotificationAssistant.TryHandleException((long)this.GetHashCode(), "Update all user's settings", exchangePrincipal.LegacyDn, ex)) { throw; } } finally { if (mailboxSession != null) { mailboxSession.Dispose(); mailboxSession = null; } } } } } } } }
internal static void UpdateRecipients(AddressBookBase abb, ADObjectId[] removedAbbTreeIds, string domainController, IRecipientSession globalCatalogSession, Task.TaskWarningLoggingDelegate writeWarning, WriteProgress writeProgress, Cmdlet cmdlet) { if (abb == null) { throw new ArgumentNullException("abb"); } if (Guid.Empty == abb.Guid) { throw new ArgumentNullException("abb.Guid"); } if (writeWarning == null) { throw new ArgumentNullException("writeWarning"); } if (writeProgress == null) { throw new ArgumentNullException("writeProgress"); } int num = 0; try { if (cmdlet != null && cmdlet.Stopping) { return; } string domainControllerFqdn = null; if (!string.IsNullOrEmpty(domainController)) { try { domainControllerFqdn = SystemConfigurationTasksHelper.GetConfigurationDomainControllerFqdn(domainController); } catch (SocketException ex) { writeWarning(Strings.ErrorResolveFqdnForDomainController(domainController, ex.Message)); return; } } if (string.IsNullOrEmpty(abb.LdapRecipientFilter) || removedAbbTreeIds != null) { List <Guid> list = new List <Guid>(); if (removedAbbTreeIds != null) { foreach (ADObjectId adobjectId in removedAbbTreeIds) { list.Add(adobjectId.ObjectGuid); } list.Sort(); } else { list.Add(abb.Guid); } QueryFilter[] array = null; int num2 = LdapFilterBuilder.MaxCustomFilterTreeSize - 1; for (int j = 0; j < list.Count; j += num2) { int num3 = Math.Min(num2, list.Count - j); if (array == null || array.Length != num3) { array = new QueryFilter[num3]; } for (int k = 0; k < num3; k++) { array[k] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, new ADObjectId(list[k + j])); } QueryFilter queryFilter = new OrFilter(array); ADPagedReader <ADRecipient> adpagedReader = globalCatalogSession.FindPaged(null, QueryScope.SubTree, queryFilter, null, 0); using (IEnumerator <ADRecipient> enumerator = adpagedReader.GetEnumerator()) { UpdateAddressBookBase <TIdParameter> .InternalUpdateRecipients(enumerator, null, queryFilter, list, domainControllerFqdn, globalCatalogSession, writeWarning, writeProgress, cmdlet, ref num); } } } else { IEnumerator <ADRecipient> enumerator2 = abb.FindUpdatingRecipientsPaged(globalCatalogSession, null).GetEnumerator(); UpdateAddressBookBase <TIdParameter> .InternalUpdateRecipients(enumerator2, abb, null, null, domainControllerFqdn, globalCatalogSession, writeWarning, writeProgress, cmdlet, ref num); } } finally { if (cmdlet != null && cmdlet.Stopping) { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_RecipientsUpdateForAddressBookCancelled, new string[] { string.Format("{0} (objectGUID=<{1}>)", abb.DistinguishedName ?? string.Empty, abb.Guid.ToString()), abb.LdapRecipientFilter, ADRecipientSchema.AddressListMembership.Name }); } } if (num != 0) { writeProgress(Strings.ProgressActivityUpdateRecipient, Strings.ProgressStatusFinished, 100); } }
public IList <ISource> ValidateAndGetFinalSourceMailboxes(string searchQuery, IList <string> sourceMailboxes, IList <string> notFoundMailboxes, IList <string> versionSkippedMailboxes, IList <string> rbacDeniedMailboxes, IList <string> crossPremiseFailedMailboxes, IDictionary <Uri, string> crossPremiseUrls) { Util.ThrowIfNullOrEmpty(searchQuery, "Search query cannot be empty."); Util.ThrowIfNull(sourceMailboxes, "sourceMailboxes"); Util.ThrowIfNull(notFoundMailboxes, "notFoundMailboxes"); Util.ThrowIfNull(versionSkippedMailboxes, "versionSkippedMailboxes"); Util.ThrowIfNull(rbacDeniedMailboxes, "rbacDeniedMailboxes"); Util.ThrowIfNull(crossPremiseFailedMailboxes, "crossPremiseFailedMailboxes"); Util.ThrowIfNull(crossPremiseUrls, "crossPremiseUrls"); List <ISource> list = new List <ISource>(); Dictionary <MiniRecipient, MailboxInfo> dictionary = new Dictionary <MiniRecipient, MailboxInfo>(); int num = 0; if (sourceMailboxes.Count == 0) { AndFilter filter = new AndFilter(new QueryFilter[] { new OrFilter(new QueryFilter[] { Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.UserMailbox), Util.CreateRecipientTypeDetailsValueFilter((RecipientTypeDetails)((ulong)int.MinValue)), Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.RemoteRoomMailbox), Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.RemoteEquipmentMailbox), Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.RemoteSharedMailbox), Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.RemoteTeamMailbox) }), new NotFilter(Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.ArbitrationMailbox)), new NotFilter(Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.MonitoringMailbox)), new NotFilter(Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.AuditLogMailbox)), new NotFilter(Util.CreateRecipientTypeDetailsValueFilter(RecipientTypeDetails.MailboxPlan)) }); this.CheckRecipientSessionIsNotNull(); ADPagedReader <StorageMiniRecipient> adpagedReader = this.recipientSession.FindPagedMiniRecipient <StorageMiniRecipient>(null, QueryScope.SubTree, filter, null, 1000, SearchMailboxCriteria.RecipientTypeDetailsProperty); using (IEnumerator <StorageMiniRecipient> enumerator = adpagedReader.GetEnumerator()) { while (enumerator.MoveNext()) { StorageMiniRecipient storageMiniRecipient = enumerator.Current; if (!storageMiniRecipient.LegacyExchangeDN.Equals(this.SearchObject.Target, StringComparison.OrdinalIgnoreCase)) { if ((long)(++num) > (long)((ulong)this.MaxMailboxesToSearch)) { throw new SearchTooManyMailboxesException((int)this.MaxMailboxesToSearch); } this.ValidateAndAddToFinalSourceMailboxes(searchQuery, storageMiniRecipient, list, versionSkippedMailboxes, rbacDeniedMailboxes, dictionary); } } goto IL_2B6; } } foreach (ADObjectId adobjectId in this.ExpandGroupMembers(sourceMailboxes, this.DiscoverySystemMailboxUser.OrganizationId, notFoundMailboxes)) { if ((this.SearchObject.Target == null || !adobjectId.Equals(this.TargetMailboxUser.Id)) && !adobjectId.Equals(this.DiscoverySystemMailboxUser.Id)) { this.CheckRecipientSessionIsNotNull(); StorageMiniRecipient storageMiniRecipient2 = this.recipientSession.ReadMiniRecipient <StorageMiniRecipient>(adobjectId, SearchMailboxCriteria.RecipientTypeDetailsProperty); if (storageMiniRecipient2 != null) { if ((long)(++num) > (long)((ulong)this.MaxMailboxesToSearch)) { throw new SearchTooManyMailboxesException((int)this.MaxMailboxesToSearch); } this.ValidateAndAddToFinalSourceMailboxes(searchQuery, storageMiniRecipient2, list, versionSkippedMailboxes, rbacDeniedMailboxes, dictionary); } else { Util.Tracer.TraceError <string>((long)this.GetHashCode(), "Unable to find mailbox: {0}", adobjectId.Name); } } } IL_2B6: if (dictionary.Count > 0) { string domain = dictionary.First <KeyValuePair <MiniRecipient, MailboxInfo> >().Value.GetDomain(); Util.Tracer.TraceDebug <string>((long)this.GetHashCode(), "Before autodiscover for cross premise domain: {0}", domain); Uri uri = null; EndPointDiscoveryInfo endPointDiscoveryInfo; bool flag = RemoteDiscoveryEndPoint.TryGetDiscoveryEndPoint(this.SearchDataProvider.OrganizationId, domain, null, null, null, out uri, out endPointDiscoveryInfo); if (endPointDiscoveryInfo != null) { ScenarioData.Current["IOC"] = ((int)endPointDiscoveryInfo.Status).ToString(); if (endPointDiscoveryInfo.Status != EndPointDiscoveryInfo.DiscoveryStatus.Success) { SearchEventLogger.Instance.LogSearchErrorEvent(ScenarioData.Current["SID"], endPointDiscoveryInfo.Message); } } if (flag) { Util.Tracer.TraceDebug <Uri>((long)this.GetHashCode(), "Auto discover Url : {1}", uri); ICredentials oauthCredentialsForAppToken = OAuthCredentials.GetOAuthCredentialsForAppToken(this.SearchDataProvider.OrganizationId, domain); List <MailboxInfo> list2 = new List <MailboxInfo>(dictionary.Count); foreach (KeyValuePair <MiniRecipient, MailboxInfo> keyValuePair in dictionary) { list2.Add(keyValuePair.Value); } IAutodiscoveryClient autodiscoveryClient = Factory.Current.CreateUserSettingAutoDiscoveryClient(list2, EwsWsSecurityUrl.FixForAnonymous(uri), oauthCredentialsForAppToken, new CallerInfo(true, null, null, string.Empty, null, null, null)); IAsyncResult result = autodiscoveryClient.BeginAutodiscover(null, null); Dictionary <GroupId, List <MailboxInfo> > dictionary2 = autodiscoveryClient.EndAutodiscover(result); if (dictionary2 != null) { using (Dictionary <GroupId, List <MailboxInfo> > .Enumerator enumerator4 = dictionary2.GetEnumerator()) { while (enumerator4.MoveNext()) { KeyValuePair <GroupId, List <MailboxInfo> > keyValuePair2 = enumerator4.Current; if (keyValuePair2.Key.GroupType == GroupType.CrossPremise) { if (!crossPremiseUrls.ContainsKey(keyValuePair2.Key.Uri)) { crossPremiseUrls.Add(keyValuePair2.Key.Uri, domain); } using (List <ISource> .Enumerator enumerator5 = list.GetEnumerator()) { while (enumerator5.MoveNext()) { ISource source = enumerator5.Current; SourceMailbox sourceMailbox = (SourceMailbox)source; foreach (MailboxInfo mailboxInfo in keyValuePair2.Value) { if (string.Compare(sourceMailbox.LegacyExchangeDN, mailboxInfo.LegacyExchangeDN, StringComparison.OrdinalIgnoreCase) == 0) { sourceMailbox.ServiceEndpoint = keyValuePair2.Key.Uri; break; } } } continue; } } if (keyValuePair2.Key.GroupType == GroupType.SkippedError) { foreach (MailboxInfo mailboxInfo2 in keyValuePair2.Value) { Util.Tracer.TraceError <SmtpAddress>((long)this.GetHashCode(), "Auto discover skipped error for mailbox: {0}", mailboxInfo2.PrimarySmtpAddress); crossPremiseFailedMailboxes.Add(mailboxInfo2.LegacyExchangeDN); } } } goto IL_5F2; } } Util.Tracer.TraceError <string>((long)this.GetHashCode(), "Auto discover results is null for domain: {0}", domain); } else { Util.Tracer.TraceError <string>((long)this.GetHashCode(), "Organization relationship is not set up for domain: {0}", domain); foreach (KeyValuePair <MiniRecipient, MailboxInfo> keyValuePair3 in dictionary) { crossPremiseFailedMailboxes.Add(keyValuePair3.Value.LegacyExchangeDN); } } } IL_5F2: if (crossPremiseFailedMailboxes.Count > 0) { foreach (string b in crossPremiseFailedMailboxes) { for (int i = list.Count - 1; i >= 0; i--) { ISource source2 = list[i]; if (source2.LegacyExchangeDN == b) { list.RemoveAt(i); } } } } return(list); }