internal static string CheckELCFolderNameUniqueness(IConfigurationSession session, ADObjectId id, string newFolderName, MultiValuedProperty <string> newLocalizedFolderNames) { ADPagedReader <ELCFolder> adpagedReader = session.FindAllPaged <ELCFolder>(); foreach (ELCFolder elcfolder in adpagedReader) { if (id == null || id != elcfolder.Id) { if (string.Compare(newFolderName, elcfolder.FolderName, true, CultureInfo.InvariantCulture) == 0) { return(newFolderName); } if (elcfolder.LocalizedFolderName != null) { foreach (string text in elcfolder.LocalizedFolderName) { int num = text.IndexOf(':'); if (string.Compare(newFolderName, 0, text, num + 1, 2147483647, true, CultureInfo.InvariantCulture) == 0) { return(newFolderName); } foreach (string text2 in newLocalizedFolderNames) { int num2 = text2.IndexOf(':'); if (string.Compare(text2, num2 + 1, text, num + 1, 2147483647, true, CultureInfo.InvariantCulture) == 0) { return(text2); } } } } } } return(null); }
private static IEnumerable <ManageExchangeCertificate.FqdnConnectors> GetConnectorFQDNs(IConfigurationSession session, Server server) { if (server == null) { return(new ManageExchangeCertificate.FqdnConnectors[0]); } ManageExchangeCertificate.FqdnConnectorsMap fqdnConnectorsMap = new ManageExchangeCertificate.FqdnConnectorsMap(); ADPagedReader <ReceiveConnector> adpagedReader = session.FindAllPaged <ReceiveConnector>(); foreach (ReceiveConnector receiveConnector in adpagedReader) { if (!string.IsNullOrEmpty(receiveConnector.Fqdn) && server.Identity.Equals(receiveConnector.Server) && (receiveConnector.AuthMechanism & AuthMechanisms.Tls) != AuthMechanisms.None) { fqdnConnectorsMap.Add(receiveConnector.Fqdn, receiveConnector.Name); } } ADPagedReader <SmtpSendConnectorConfig> adpagedReader2 = session.FindAllPaged <SmtpSendConnectorConfig>(); foreach (SmtpSendConnectorConfig smtpSendConnectorConfig in adpagedReader2) { if (!string.IsNullOrEmpty(smtpSendConnectorConfig.Fqdn) && smtpSendConnectorConfig.DNSRoutingEnabled && smtpSendConnectorConfig.DomainSecureEnabled && smtpSendConnectorConfig.SourceTransportServers.Contains(server.Id)) { fqdnConnectorsMap.Add(smtpSendConnectorConfig.Fqdn, smtpSendConnectorConfig.Name); } } return(fqdnConnectorsMap); }
private void ExpandGroupMembership(ReducedRecipient groupRecipient, MultiValuedProperty <BindingMetadata> validatedRecipients) { QueryFilter filter = QueryFilter.AndTogether(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MemberOfGroup, groupRecipient.Guid), new ComparisonFilter(ComparisonOperator.Equal, SharedPropertyDefinitions.FfoExpansionSizeUpperBoundFilter, this.maxRecipientsLimit) }); try { ADPagedReader <ADRawEntry> adpagedReader = this.recipientSession.FindPagedADRawEntry(null, QueryScope.SubTree, filter, null, 1000, ExchangeValidator.memberOfProperties); foreach (ADRawEntry adrawEntry in adpagedReader) { RecipientIdParameter arg = RecipientIdParameter.Parse(adrawEntry.Id.ObjectGuid.ToString()); ReducedRecipient recipient = this.recipientGetter(arg, this.recipientSession); this.VerifyAndAddRecipient(recipient, validatedRecipients, true); } } catch (FfoSizeLimitReachedException ex) { base.LogOneEntry(ExecutionLog.EventType.Error, "InvalidArgument: {0}, Exception: {1}", new object[] { Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit), ex }); base.WriteError(new ExValidatorException(Strings.ErrorMaxMailboxLimitReachedInGroupExpansion(this.maxRecipientsLimit), ex), ErrorCategory.InvalidArgument); } }
public static IList<RoutingGroupConnector> GetAlternateRgcs(RoutingGroupConnector connectorBeingProcessed, IConfigurationSession session, out RoutingGroupConnector savedConnector) { TaskLogger.Trace("Reading alternate RGCs for RG '{0}'", new object[] { connectorBeingProcessed.SourceRoutingGroup }); ADPagedReader<RoutingGroupConnector> adpagedReader = session.FindPaged<RoutingGroupConnector>(connectorBeingProcessed.SourceRoutingGroup, QueryScope.SubTree, null, null, ADGenericPagedReader<RoutingGroupConnector>.DefaultPageSize); savedConnector = null; IList<RoutingGroupConnector> list = new List<RoutingGroupConnector>(); foreach (RoutingGroupConnector routingGroupConnector in adpagedReader) { if (connectorBeingProcessed.TargetRoutingGroup.Equals(routingGroupConnector.TargetRoutingGroup)) { if (connectorBeingProcessed.Id.Equals(routingGroupConnector.Id)) { savedConnector = routingGroupConnector; } else { list.Add(routingGroupConnector); } } } TaskLogger.Trace("Found {0} alternate RGCs", new object[] { list.Count }); return list; }
// Token: 0x060009CA RID: 2506 RVA: 0x0002121C File Offset: 0x0001F41C internal override IEnumerable <T> GetObjects <T>(ADObjectId rootId, IDirectorySession session, IDirectorySession subTreeSession, OptionalIdentityData optionalData, out LocalizedString?notFoundReason) { if (typeof(T) != typeof(ExtendedRight)) { throw new ArgumentException(Strings.ErrorInvalidType(typeof(T).Name), "type"); } if (session == null) { throw new ArgumentNullException("session"); } if (ExtendedRightIdParameter.AllExtendedRights == null) { ADPagedReader <ExtendedRight> adpagedReader = ((ITopologyConfigurationSession)session).GetAllExtendedRights(); ExtendedRightIdParameter.allExtendedRights = adpagedReader.ReadAllPages(); } base.GetObjects <T>(rootId, session, subTreeSession, optionalData, out notFoundReason); List <T> list = new List <T>(); foreach (ExtendedRight extendedRight in ExtendedRightIdParameter.AllExtendedRights) { if (ADObjectId.Equals(extendedRight.Id, base.InternalADObjectId) || (base.InternalADObjectId != null && base.InternalADObjectId.ObjectGuid == extendedRight.RightsGuid) || (base.RawIdentity != null && (string.Compare(extendedRight.DisplayName, base.RawIdentity, StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(extendedRight.Name, base.RawIdentity, StringComparison.OrdinalIgnoreCase) == 0))) { list.Add((T)((object)extendedRight)); break; } } return(list); }
private void RenameEndUserRolesForUnifiedRAP() { if (base.ServicePlanSettings == null || base.ServicePlanSettings.Organization.PerMBXPlanRoleAssignmentPolicyEnabled || base.InvocationMode == InvocationMode.Install) { return; } ADPagedReader <ExchangeRole> adpagedReader = this.configurationSession.FindPaged <ExchangeRole>(this.rolesContainerId, QueryScope.OneLevel, null, null, 0); List <ExchangeRole> list = new List <ExchangeRole>(); foreach (ExchangeRole exchangeRole in adpagedReader) { base.LogReadObject(exchangeRole); if (exchangeRole.IsEndUserRole && exchangeRole.IsRootRole) { list.Add(exchangeRole); } } this.RenameCannedEndUserRoles(list); adpagedReader = this.configurationSession.FindPaged <ExchangeRole>(this.rolesContainerId, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, ExchangeRoleSchema.IsEndUserRole, true), null, 0); list = new List <ExchangeRole>(); foreach (ExchangeRole exchangeRole2 in adpagedReader) { base.LogReadObject(exchangeRole2); if (exchangeRole2.IsEndUserRole && exchangeRole2.Name.Contains("_DefaultMailboxPlan")) { list.Add(exchangeRole2); } } this.RenameCannedEndUserRoles(list); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); try { IEnumerable <TDataObject> pagedData = this.GetPagedData(); ADPagedReader <TDataObject> adpagedReader = pagedData as ADPagedReader <TDataObject>; if (adpagedReader != null) { this.RequestQueryFilterInGetTasks = adpagedReader.LdapFilter; base.WriteVerbose(Strings.VerboseRequestFilterInGetTask(this.RequestQueryFilterInGetTasks)); } if (this.InternalFilter != null) { this.InternalQueryFilterInGetTasks = this.InternalFilter.ToString(); base.WriteVerbose(Strings.VerboseInternalQueryFilterInGetTasks(this.InternalQueryFilterInGetTasks)); } this.pageInfo = (pagedData as IPageInformation); this.WriteResult <TDataObject>(pagedData); } catch (DataSourceTransientException exception) { base.WriteError(exception, (ErrorCategory)1002, null); } TaskLogger.LogExit(); }
protected override IEnumerable <ClassificationRulePackage> Read(IConfigurationSession session) { ADPagedReader <TransportRule> adpagedReader = session.FindPaged <TransportRule>(PerTenantClassificationDefinitionCollection.GetClassificationDefinitionsContainerId(session), QueryScope.SubTree, null, PerTenantClassificationDefinitionCollection.PriorityOrder, 0); TransportRule[] source = adpagedReader.ReadAllPages(); ClassificationParser parser = ClassificationParser.Instance; return((from rule in source.Select(delegate(TransportRule adRule) { try { ClassificationRulePackage rulePackage = parser.GetRulePackage(adRule.ReplicationSignature); rulePackage.Version = (adRule.WhenChangedUTC ?? (adRule.WhenCreatedUTC ?? DateTime.MinValue)); rulePackage.ID = adRule.Name; return rulePackage; } catch (ParserException ex) { PerTenantClassificationDefinitionCollection.Tracer.TraceError <ADObjectId, Exception>((long)this.GetHashCode(), "Rule with identity {0} is corrupted and will not be returned to clients. Details: {1}", adRule.Id, ex); CachedOrganizationConfiguration.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptClassificationDefinition, adRule.Id.ToString(), new object[] { adRule.Id, ex }); } return null; }) where rule != null select rule).ToList <ClassificationRulePackage>()); }
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); }
private static IEnumerable <ServerInfo> GetServersInSiteByRole(IConfigurationSession session, QueryFilter roleFilter, ADObjectId site) { ComparisonFilter userSiteFilter = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, site); AndFilter queryFilter = new AndFilter(new QueryFilter[] { userSiteFilter, roleFilter }); ADPagedReader <Server> servers = session.FindPaged <Server>(null, QueryScope.SubTree, queryFilter, null, 0); foreach (Server server in servers) { ServerInfo serverInfo = ServerInfo.CreateServerInfoFromServer(server); if (!serverInfo.IsSearchable) { TraceWrapper.SearchLibraryTracer.TraceDebug <string>(0, "Server: {0}, not searchable", serverInfo.Key); } else if (string.IsNullOrEmpty(server.Fqdn)) { TraceWrapper.SearchLibraryTracer.TraceError(0, "Null/empty server-name, skipping", new object[0]); } else { yield return(serverInfo); } } yield break; }
internal EnhancedTimeSpan?GetTimeSpanForRetention() { ADPagedReader <ElcContentSettings> elccontentSettings = this.GetELCContentSettings(); EnhancedTimeSpan?result = null; if (elccontentSettings != null) { foreach (ElcContentSettings elcContentSettings in elccontentSettings) { if (elcContentSettings.RetentionEnabled && elcContentSettings.AgeLimitForRetention != null && (elcContentSettings.RetentionAction == RetentionActionType.DeleteAndAllowRecovery || elcContentSettings.RetentionAction == RetentionActionType.PermanentlyDelete || elcContentSettings.RetentionAction == RetentionActionType.MoveToDeletedItems)) { if (result != null) { return(null); } result = elcContentSettings.AgeLimitForRetention; } } } if (result == null) { result = new EnhancedTimeSpan?(TimeSpan.MaxValue); } return(result); }
private void RetrieveAllScopes(ScopeRestrictionType scopeType, ADRawEntry givenObject, out Dictionary <ADObjectId, ADScope> customScopes, out Dictionary <ADObjectId, ADScope> exclusiveScopes) { customScopes = new Dictionary <ADObjectId, ADScope>(); exclusiveScopes = new Dictionary <ADObjectId, ADScope>(); ScopeType scopeType2 = ScopeType.ExclusiveConfigScope; ScopeType scopeType3 = ScopeType.CustomConfigScope; if (scopeType == ScopeRestrictionType.RecipientScope) { scopeType2 = ScopeType.ExclusiveRecipientScope; scopeType3 = ScopeType.CustomRecipientScope; } ADPagedReader <ManagementScope> allScopes = this.configSession.GetAllScopes(this.orgId, scopeType); foreach (ManagementScope managementScope in allScopes) { if (managementScope.ScopeRestrictionType == scopeType) { ExchangeRunspaceConfiguration.TryStampQueryFilterOnManagementScope(managementScope); if (managementScope.Exclusive) { RbacScope rbacScope = new RbacScope(scopeType2, managementScope); rbacScope.PopulateRootAndFilter(this.orgId, givenObject); exclusiveScopes.Add(managementScope.OriginalId, rbacScope); } RbacScope rbacScope2 = new RbacScope(scopeType3, managementScope); rbacScope2.PopulateRootAndFilter(this.orgId, givenObject); customScopes.Add(managementScope.OriginalId, rbacScope2); } } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (!this.Force && SharedConfiguration.IsSharedConfiguration(base.DataObject.OrganizationId) && !base.ShouldContinue(Strings.ConfirmSharedConfiguration(base.DataObject.OrganizationId.OrganizationalUnit.Name))) { TaskLogger.LogExit(); return; } ADPagedReader <ADRawEntry> adpagedReader = this.ConfigurationSession.FindPagedADRawEntryWithDefaultFilters <ExchangeRole>(base.DataObject.Id, this.Recurse ? QueryScope.SubTree : QueryScope.Base, new ExistsFilter(ExchangeRoleSchema.RoleAssignments), null, 0, new PropertyDefinition[] { ADObjectSchema.Id, ExchangeRoleSchema.RoleAssignments }); foreach (ADRawEntry adrawEntry in adpagedReader) { base.WriteError(new InvalidOperationException(Strings.ErrorCannotDeleteRoleWithAssignment(adrawEntry.Id.ToString())), ErrorCategory.InvalidOperation, base.DataObject.Id); } if (this.Recurse) { ((IConfigurationSession)base.DataSession).DeleteTree(base.DataObject, new TreeDeleteNotFinishedHandler(this.ReportDeleteTreeProgress)); } else { base.InternalProcessRecord(); } TaskLogger.LogExit(); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (!base.HasErrors) { if ((!base.DataObject.IsUnscopedTopLevel || !this.UnScopedTopLevel) && base.DataObject.IsRootRole) { base.WriteError(new InvalidOperationException(Strings.ErrorCannotDeletePrecannedRole(this.Identity.ToString())), ErrorCategory.InvalidOperation, base.DataObject.Id); } if (!base.DataObject.IsUnscopedTopLevel && this.UnScopedTopLevel) { base.WriteError(new InvalidOperationException(Strings.ParameterAllowedOnlyForTopLevelRoleManipulation("UnScopedTopLevel", RoleType.UnScoped.ToString())), ErrorCategory.InvalidOperation, null); } } ADPagedReader <ADRawEntry> adpagedReader = this.ConfigurationSession.FindPagedADRawEntryWithDefaultFilters <ExchangeRole>(base.DataObject.Id, this.Recurse ? QueryScope.SubTree : QueryScope.Base, null, null, 0, new PropertyDefinition[] { ADObjectSchema.Id }); StringBuilder stringBuilder = new StringBuilder(); foreach (ADRawEntry adrawEntry in adpagedReader) { stringBuilder.Append("\n\t"); stringBuilder.Append(adrawEntry.Id.ToString()); } this.rolesToRemove = stringBuilder.ToString(); TaskLogger.LogExit(); }
private void CreateNewSCP() { DirectoryEntry directoryEntry = this.mea.Children.Add(this.ConfigCN(), "ServiceConnectionPoint"); directoryEntry.Properties["Keywords"].Add("67661d7F-8FC4-4fa7-BFAC-E1D7794C1F68"); if (this.MultipleExchangeDeployments) { ADPagedReader <AcceptedDomain> adpagedReader = this.sourceConfigSession.FindAllPaged <AcceptedDomain>(); int num = 0; if (adpagedReader != null) { foreach (AcceptedDomain acceptedDomain in adpagedReader) { num++; if (acceptedDomain.DomainType == AcceptedDomainType.Authoritative) { directoryEntry.Properties["Keywords"].Add("Domain=" + acceptedDomain.DomainName.Domain); } } } if (num == 0) { this.WriteWarning(Strings.EADCWeakSourceCreds); } } directoryEntry.Properties["ServiceBindingInformation"].Value = "LDAP://" + this.SourceForestFqdn(); directoryEntry.CommitChanges(); }
protected override IEnumerable <OutlookProtectionRule> Read(IConfigurationSession session) { ADPagedReader <TransportRule> adpagedReader = session.FindPaged <TransportRule>(PerTenantProtectionRulesCollection.GetProtectionRuleContainerId(session), QueryScope.SubTree, null, PerTenantProtectionRulesCollection.PriorityOrder, 0); TransportRule[] array = adpagedReader.ReadAllPages(); List <OutlookProtectionRule> list = new List <OutlookProtectionRule>(array.Length); OutlookProtectionRuleParser instance = OutlookProtectionRuleParser.Instance; foreach (TransportRule transportRule in array) { try { list.Add((OutlookProtectionRule)instance.GetRule(transportRule.Xml)); } catch (ParserException ex) { PerTenantProtectionRulesCollection.Tracer.TraceError <ADObjectId, Exception>((long)this.GetHashCode(), "Rule with identity {0} is corrupted and will not be returned to clients. Details: {1}", transportRule.Id, ex); CachedOrganizationConfiguration.Logger.LogEvent(InfoWorkerEventLogConstants.Tuple_CorruptOutlookProtectionRule, transportRule.Id.ToString(), new object[] { transportRule.Id, ex }); } } return(list); }
private static List <RetentionPolicyTag> GetTheGoodTags(ADPagedReader <RetentionPolicyTag> allAdTags) { List <RetentionPolicyTag> list = new List <RetentionPolicyTag>(); foreach (RetentionPolicyTag retentionPolicyTag in allAdTags) { ValidationError[] array = retentionPolicyTag.ValidateRead(); if (array != null && array.Length > 0) { foreach (ValidationError validationError in array) { AdReader.Tracer.TraceError <string>(0L, "The retentionPolicyTag '{0}' has a validation error.", retentionPolicyTag.Name); if (!(validationError is PropertyValidationError)) { AdReader.Tracer.TraceError <Type, LocalizedString>(0L, "The error type is '{0}'. Validation error: {1}", validationError.GetType(), validationError.Description); throw new DataValidationException(validationError); } PropertyDefinition propertyDefinition = ((PropertyValidationError)validationError).PropertyDefinition; if (propertyDefinition != RetentionPolicyTagSchema.Type) { AdReader.Tracer.TraceError <Type, string, LocalizedString>(0L, "The error type is '{0}'. Property '{1}' has a property validation error: {2}", validationError.GetType(), propertyDefinition.Name, validationError.Description); throw new DataValidationException(validationError); } AdReader.Tracer.TraceError <string>(0L, "This tag is of unknown type. Skipping tag '{0}'", retentionPolicyTag.Name); } } else { list.Add(retentionPolicyTag); } } return(list); }
public OrganizationSettingsData(ActiveSyncOrganizationSettings organizationSettings, IConfigurationSession scopedSession) { if (scopedSession == null) { throw new ArgumentNullException("scopedSession"); } if (organizationSettings == null) { throw new ArgumentNullException("organizationSettings"); } this.Identity = organizationSettings.OriginalId; this.defaultAccessLevel = organizationSettings.DefaultAccessLevel; this.userMailInsert = organizationSettings.UserMailInsert; this.allowAccessForUnSupportedPlatform = organizationSettings.AllowAccessForUnSupportedPlatform; this.adminMailRecipients = organizationSettings.AdminMailRecipients; this.otaNotificationMailInsert = organizationSettings.OtaNotificationMailInsert; this.deviceFiltering = null; this.IsIntuneManaged = organizationSettings.IsIntuneManaged; if (organizationSettings.DeviceFiltering != null && organizationSettings.DeviceFiltering.DeviceFilters != null) { this.deviceFiltering = organizationSettings.DeviceFiltering.DeviceFilters.ToDictionary((ActiveSyncDeviceFilter deviceFilter) => deviceFilter.Name); } ADPagedReader <ActiveSyncDeviceAccessRule> adpagedReader = scopedSession.FindPaged <ActiveSyncDeviceAccessRule>(organizationSettings.Id, QueryScope.OneLevel, null, null, 0); foreach (ActiveSyncDeviceAccessRule deviceAccessRule in adpagedReader) { ((IOrganizationSettingsData)this).AddOrUpdateDeviceAccessRule(deviceAccessRule); } this.organizationId = organizationSettings.OrganizationId; }
protected override void InternalProcessRecord() { base.InternalProcessRecord(); Dictionary <string, bool> dictionary = new Dictionary <string, bool>(); List <ExchangeRole> list = new List <ExchangeRole>(); foreach (ServicePlan.MailboxPlan mailboxPlan in this.ServicePlanSettings.MailboxPlans) { if (!string.IsNullOrEmpty(mailboxPlan.MailboxPlanIndex)) { dictionary[mailboxPlan.MailboxPlanIndex] = true; } } ADPagedReader <ExchangeRole> adpagedReader = this.configurationSession.FindAllPaged <ExchangeRole>(); foreach (ExchangeRole exchangeRole in adpagedReader) { if (exchangeRole.IsRootRole && !string.IsNullOrEmpty(exchangeRole.MailboxPlanIndex) && dictionary.ContainsKey(exchangeRole.MailboxPlanIndex)) { list.Add(exchangeRole); } } ADObjectId descendantId = base.OrgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer); foreach (ExchangeRole exchangeRole2 in list) { this.RemoveRoleTreeAndAssignments(exchangeRole2.Id, descendantId); } }
public static ADUser GetDiscoveryUserMailbox(IRecipientSession session) { if (session == null) { throw new ArgumentNullException("session"); } IRecipientSession recipientSession = session; if (recipientSession.ConfigScope != ConfigScopes.TenantLocal) { recipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(session.DomainController, true, ConsistencyMode.PartiallyConsistent, session.NetworkCredential, session.SessionSettings, 156, "GetDiscoveryUserMailbox", "f:\\15.00.1497\\sources\\dev\\data\\src\\storage\\Search\\MailboxSearch\\MailboxDataProvider.cs"); recipientSession.UseGlobalCatalog = true; recipientSession.EnforceDefaultScope = session.EnforceDefaultScope; } ADPagedReader <ADRecipient> adpagedReader = recipientSession.FindPaged(null, QueryScope.SubTree, MailboxDataProvider.DiscoveryUserMailboxFilter, null, 10); foreach (ADRecipient adrecipient in adpagedReader) { ADUser aduser = (ADUser)adrecipient; ADUser aduser2 = aduser; if (ExchangePrincipal.FromADUser(recipientSession.SessionSettings, aduser2, RemotingOptions.AllowCrossSite).MailboxInfo.Location.ServerVersion >= Server.E14SP1MinVersion) { return(aduser2); } } throw new ObjectNotFoundException(ServerStrings.UserDiscoveryMailboxNotFound); }
private static void ExtractTheGoodFolders(ADPagedReader <ELCFolder> elcFolders, List <ELCFolder> elcFoldersToReturn) { foreach (ELCFolder elcfolder in elcFolders) { ValidationError[] array = elcfolder.ValidateRead(); if (array != null && array.Length > 0) { foreach (ValidationError validationError in array) { AdReader.Tracer.TraceError <string>(0L, "The elcFolder '{0}' has a validation error.", elcfolder.Name); if (!(validationError is PropertyValidationError)) { AdReader.Tracer.TraceError <Type, LocalizedString>(0L, "The error type is '{0}'. Validation error: {1}", validationError.GetType(), validationError.Description); throw new DataValidationException(validationError); } PropertyDefinition propertyDefinition = ((PropertyValidationError)validationError).PropertyDefinition; if (propertyDefinition != ELCFolderSchema.FolderType) { AdReader.Tracer.TraceError <Type, string, LocalizedString>(0L, "The error type is '{0}'. Property '{1}' has a property validation error: {2}", validationError.GetType(), propertyDefinition.Name, validationError.Description); throw new DataValidationException(validationError); } AdReader.Tracer.TraceError <string>(0L, "New default folder types were added. Skipping folder '{0}' because this version of Exchange can't handle it.", elcfolder.Name); } } else { elcFoldersToReturn.Add(elcfolder); } } }
private static OrganizationConfigCache.Item GetOrgSettings(IConfigurationSession tenantConfigSession, ref bool shouldAdd) { Organization orgContainer = tenantConfigSession.GetOrgContainer(); if (orgContainer == null) { TraceWrapper.SearchLibraryTracer.TraceError(0, "ADSystemConfigurationSession.GetOrgContainer returned null", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "msExchOrganizationContainer object not found", new object[0]); } bool readTrackingEnabled = orgContainer.ReadTrackingEnabled; QueryFilter filter = new NotFilter(new BitMaskAndFilter(AcceptedDomainSchema.AcceptedDomainFlags, 1UL)); ADPagedReader <AcceptedDomain> adpagedReader = tenantConfigSession.FindPaged <AcceptedDomain>(tenantConfigSession.GetOrgContainerId(), QueryScope.SubTree, filter, null, 0); HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); HashSet <string> hashSet2 = new HashSet <string>(StringComparer.OrdinalIgnoreCase); string text = null; int num = 0; int num2 = 0; foreach (AcceptedDomain acceptedDomain in adpagedReader) { num2++; if (acceptedDomain.Default) { text = acceptedDomain.DomainName.Domain; } if (acceptedDomain.DomainType == AcceptedDomainType.Authoritative) { if (++num > 200) { shouldAdd = false; } hashSet.Add(acceptedDomain.DomainName.Domain); } else if (acceptedDomain.DomainType == AcceptedDomainType.InternalRelay) { if (++num > 200) { shouldAdd = false; } hashSet2.Add(acceptedDomain.DomainName.Domain); } } if (num2 == 0) { TraceWrapper.SearchLibraryTracer.TraceError(0, "No AcceptedDomain objects returned", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "msExchAcceptedDomain object not found in Organization {0}", new object[] { orgContainer }); } if (string.IsNullOrEmpty(text)) { TraceWrapper.SearchLibraryTracer.TraceError(0, "Null/Empty AcceptedDomainFqdn returned", new object[0]); TrackingFatalException.RaiseED(ErrorCode.InvalidADData, "DefaultDomain not found in Organization {0}", new object[] { orgContainer }); } return(new OrganizationConfigCache.Item(text, readTrackingEnabled, hashSet, hashSet2)); }
// Token: 0x06000DBC RID: 3516 RVA: 0x0002905C File Offset: 0x0002725C internal override IEnumerable <T> PerformSearch <T>(QueryFilter filter, ADObjectId rootId, IDirectorySession session, bool deepSearch) { ADObjectId deletedObjectsContainer = ADSession.GetDeletedObjectsContainer(session.GetDomainNamingContext()); ADPagedReader <RemovedMailbox> adpagedReader = session.FindPagedDeletedObject <RemovedMailbox>(deletedObjectsContainer, QueryScope.OneLevel, filter, null, 0); return((IEnumerable <T>)adpagedReader); }
public static bool TryLoadLocalSiteTopology(string domainController, out ReplicationTopology topology, out Exception exception) { topology = null; exception = null; ITopologyConfigurationSession session = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController, true, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 154, "TryLoadLocalSiteTopology", "f:\\15.00.1497\\sources\\dev\\EdgeSync\\src\\Common\\Validation\\ReplicationTopology.cs"); ADSite localSite = null; EdgeSyncServiceConfig edgeSyncServiceConfig = null; ADOperationResult adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { localSite = session.GetLocalSite(); if (localSite == null) { throw new ADTransientException(Strings.CannotGetLocalSite); } edgeSyncServiceConfig = session.Read <EdgeSyncServiceConfig>(localSite.Id.GetChildId("EdgeSyncService")); }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } if (edgeSyncServiceConfig == null) { topology = new ReplicationTopology(session, null, localSite, null); return(true); } ReplicationTopology resultTopology = null; adoperationResult = ADNotificationAdapter.TryRunADOperation(delegate() { Server server = session.FindLocalServer(); resultTopology = new ReplicationTopology(session, server, localSite, edgeSyncServiceConfig); QueryFilter filter = Util.BuildServerFilterForSite(localSite.Id); ADPagedReader <Server> adpagedReader = session.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); resultTopology.siteEdgeServers.Clear(); resultTopology.siteHubServers.Clear(); foreach (Server server2 in adpagedReader) { if (server2.IsEdgeServer) { resultTopology.siteEdgeServers.Add(server2); } if (server2.IsHubTransportServer) { resultTopology.siteHubServers.Add(server2); } } }, 3); if (!adoperationResult.Succeeded) { exception = adoperationResult.Exception; return(false); } topology = resultTopology; return(true); }
internal List <RecipientData> ExpandDistributionGroup(RecipientData recipientData, DateTime queryPrepareDeadline, out bool groupCapped) { List <RecipientData> list = new List <RecipientData>(Configuration.MaximumGroupMemberCount); groupCapped = false; int num = 0; Queue <RecipientData> queue = new Queue <RecipientData>(Configuration.MaximumGroupMemberCount); HashSet <Guid> hashSet = new HashSet <Guid>(Configuration.MaximumGroupMemberCount); queue.Enqueue(recipientData); hashSet.Add(recipientData.Guid); while (queue.Count > 0 && !groupCapped) { RecipientData recipientData2 = queue.Dequeue(); QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.MemberOfGroup, recipientData2.Id); ADPagedReader <ADRecipient> adpagedReader = base.ADRecipientSession.FindPaged(null, QueryScope.SubTree, filter, null, Configuration.MaximumGroupMemberCount); ExTraceGlobals.DistributionListHandlingTracer.TraceDebug <object, SmtpAddress, int>((long)this.GetHashCode(), "{0}: Expanding group {1}, which has {2} members.", TraceContext.Get(), recipientData.PrimarySmtpAddress, recipientData.DistributionGroupMembersCount); foreach (ADRecipient adrecipient in adpagedReader) { if (DateTime.UtcNow > queryPrepareDeadline) { groupCapped = true; break; } if (!hashSet.Contains(adrecipient.Guid)) { hashSet.Add(adrecipient.Guid); if (adrecipient is ADUser || adrecipient is ADContact) { if (list.Count >= Configuration.MaximumGroupMemberCount) { groupCapped = true; break; } EmailAddress emailAddress = RecipientQuery.CreateEmailAddressFromADRecipient(adrecipient); list.Add(RecipientData.Create(emailAddress, adrecipient, base.PropertyDefinitionArray)); } else if (adrecipient is ADGroup) { EmailAddress emailAddress2 = RecipientQuery.CreateEmailAddressFromADRecipient(adrecipient); ADGroup configurableObject = (ADGroup)adrecipient; queue.Enqueue(RecipientData.Create(emailAddress2, configurableObject, base.PropertyDefinitionArray)); } else { ExTraceGlobals.DistributionListHandlingTracer.TraceDebug <object, ADRecipient>((long)this.GetHashCode(), "{0}: Group member {1} is not a ADUser, ADContact or ADGroup. This member is not being processed.", TraceContext.Get(), adrecipient); } } else { ExTraceGlobals.DistributionListHandlingTracer.TraceDebug <object, ADRecipient>((long)this.GetHashCode(), "{0}: Group member {1} has been found to be a duplicate and not being processed.", TraceContext.Get(), adrecipient); num++; } } } return(list); }
internal static List <RetentionPolicy> GetAllRetentionPolicies(IConfigurationSession session, OrganizationId organizationId) { ADPagedReader <RetentionPolicy> source = session.FindPaged <RetentionPolicy>(null, QueryScope.SubTree, null, null, 0); List <RetentionPolicy> list = source.ToList <RetentionPolicy>(); string arg = (organizationId.ConfigurationUnit == null) ? "First Organization" : organizationId.ConfigurationUnit.ToString(); AdReader.Tracer.TraceDebug <int, string>(0L, "Found {0} retention policies for {1} in AD.", list.Count, arg); return(list); }
internal static void LoadFoldersInOrg(OrganizationId orgId, List <ELCFolder> allFolders) { ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(orgId); IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, sessionSettings, 175, "LoadFoldersInOrg", "f:\\15.00.1497\\sources\\dev\\infoworker\\src\\common\\ELC\\AdFolderReader.cs"); ADPagedReader <ELCFolder> elcFolders = tenantOrTopologyConfigurationSession.FindPaged <ELCFolder>(null, QueryScope.SubTree, null, null, 0); AdReader.Tracer.TraceDebug(0L, "Found ELCFolders in the AD."); AdFolderReader.ExtractTheGoodFolders(elcFolders, allFolders); }
// Token: 0x0600075B RID: 1883 RVA: 0x0002B236 File Offset: 0x00029436 public ClientAccessArray[] GetClientAccessArrays() { ClientAccessArray[] arrays = null; ADNotificationAdapter.TryRunADOperation(delegate() { ADPagedReader <ClientAccessArray> adpagedReader = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(2, ADSessionSettings.FromRootOrgScopeSet(), 50, "GetClientAccessArrays", "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RpcHttp\\Directory.cs").FindPaged <ClientAccessArray>(null, 2, ClientAccessArray.PriorTo15ExchangeObjectVersionFilter, null, 0, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RpcHttp\\Directory.cs", 53, "GetClientAccessArrays"); arrays = adpagedReader.ReadAllPages(); }); return(arrays); }
// Token: 0x0600075C RID: 1884 RVA: 0x0002B25B File Offset: 0x0002945B public Server[] GetServers() { Server[] servers = null; ADNotificationAdapter.TryRunADOperation(delegate() { ADPagedReader <Server> adpagedReader = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(2, ADSessionSettings.FromRootOrgScopeSet(), 70, "GetServers", "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RpcHttp\\Directory.cs").FindPaged <Server>(null, 2, null, null, 0, "d:\\dbs\\sh\\e16df\\0212_214120_0\\cmd\\1g\\sources\\Dev\\Cafe\\src\\HttpProxy\\RpcHttp\\Directory.cs", 73, "GetServers"); servers = adpagedReader.ReadAllPages(); }); return(servers); }
private void RemoveAllEdgeSyncedRecipients() { IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.IgnoreInvalid, ADSessionSettings.FromRootOrgScopeSet(), 324, "RemoveAllEdgeSyncedRecipients", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\ExchangeServer\\RemoveEdgeSubscription.cs"); ADPagedReader <ADRecipient> adpagedReader = tenantOrRootOrgRecipientSession.FindPaged(null, QueryScope.SubTree, new TextFilter(ADRecipientSchema.EmailAddresses, "sh:", MatchOptions.Prefix, MatchFlags.IgnoreCase), null, 0); foreach (ADRecipient instanceToDelete in adpagedReader) { tenantOrRootOrgRecipientSession.Delete(instanceToDelete); } }