protected override void InternalProcessRecord() { TaskLogger.LogEnter(); this.mailboxSettingOnlyPolicyIgnored = false; base.InternalProcessRecord(); if (this.Identity == null && !this.IncludeMailboxSettingOnlyPolicy.IsPresent) { try { this.mailboxSettingOnlyPolicyIgnored = true; QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, EmailAddressPolicySchema.PolicyOptionListValue, EmailAddressPolicy.PolicyGuid.ToByteArray()); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(EmailAddressPolicy), filter, this.RootId, this.DeepSearch)); EmailAddressPolicy[] array = (base.DataSession as IConfigurationSession).Find <EmailAddressPolicy>((ADObjectId)this.RootId, this.DeepSearch ? QueryScope.SubTree : QueryScope.OneLevel, filter, null, 1); this.mailboxSettingOnlyPolicyIgnored = (0 != array.Length); } catch (DataSourceTransientException ex) { base.WriteVerbose(ex.LocalizedString); } catch (DataSourceOperationException ex2) { base.WriteVerbose(ex2.LocalizedString); } } if (this.mailboxSettingOnlyPolicyIgnored) { this.WriteWarning(Strings.WarningIgnoreMailboxSettingOnlyPolicy); } TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); base.InternalProcessRecord(); try { QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, MailboxDatabaseSchema.OriginalDatabase, new ADObjectId(null, base.DataObject.Id.ObjectGuid)); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(MailboxDatabase), filter, null, true)); MailboxDatabase[] array = this.ConfigurationSession.Find <MailboxDatabase>(null, QueryScope.SubTree, filter, null, 1); if (array.Length == 1) { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.ConfigurationSession)); array[0].OriginalDatabase = null; base.WriteVerbose(Strings.VerboseResetRecoveryDatabase(array[0].Id.ToString())); base.DataSession.Save(array[0]); } } catch (DataSourceTransientException ex) { this.WriteWarning(Strings.FailedToResetRecoveryDatabase(this.Identity.ToString(), ex.Message)); } catch (DataSourceOperationException ex2) { this.WriteWarning(Strings.FailedToResetRecoveryDatabase(this.Identity.ToString(), ex2.Message)); } catch (DataValidationException ex3) { this.WriteWarning(Strings.FailedToResetRecoveryDatabase(this.Identity.ToString(), ex3.Message)); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.ConfigurationSession)); } TaskLogger.LogExit(); }
protected override IEnumerable <RemovedMailbox> GetPagedData() { base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(RemovedMailbox), this.InternalFilter, null, this.DeepSearch)); RemovedMailboxIdParameter removedMailboxIdParameter = new RemovedMailboxIdParameter("*"); return(removedMailboxIdParameter.GetObjects <RemovedMailbox>(this.RootId, base.DataSession)); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); if (this.RootId != null) { try { base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch)); LocalizedString? localizedString; IEnumerable <TDataObject> objects = new DatabaseIdParameter { AllowInvalid = true }.GetObjects <TDataObject>(this.RootId, base.DataSession, base.OptionalIdentityData, out localizedString); this.WriteResult <TDataObject>(objects); goto IL_7E; } catch (DataSourceTransientException exception) { base.WriteError(exception, ErrorCategory.ReadError, null); goto IL_7E; } } base.InternalProcessRecord(); IL_7E: TaskLogger.LogExit(); }
protected override void InternalProcessRecord() { if (((IConfigurationSession)base.DataSession).GetOrgContainer().OrganizationId == OrganizationId.ForestWideOrgId) { base.InternalProcessRecord(); return; } if (this.Identity == null) { base.InternalProcessRecord(); try { base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(ActiveSyncDeviceAccessRule), this.InternalFilter, base.GlobalConfigSession.GetOrgContainerId(), this.DeepSearch)); IEnumerable <ActiveSyncDeviceAccessRule> dataObjects = base.GlobalConfigSession.FindPaged <ActiveSyncDeviceAccessRule>(base.GlobalConfigSession.GetOrgContainerId(), QueryScope.SubTree, this.InternalFilter, this.InternalSortBy, this.PageSize); this.WriteResult <ActiveSyncDeviceAccessRule>(dataObjects); return; } catch (DataSourceTransientException exception) { base.WriteError(exception, (ErrorCategory)1002, null); return; } } LocalizedString?localizedString; IEnumerable <ActiveSyncDeviceAccessRule> dataObjects2 = base.GetDataObjects <ActiveSyncDeviceAccessRule>(this.Identity, base.GlobalConfigSession, base.GlobalConfigSession.GetOrgContainerId(), base.OptionalIdentityData, out localizedString); this.WriteResult <ActiveSyncDeviceAccessRule>(dataObjects2); if (!base.HasErrors && base.WriteObjectCount == 0U) { base.InternalProcessRecord(); } }
protected override IEnumerable <ReducedRecipient> GetPagedData() { if (this.usingALbasedVlv) { base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsInALVerboseString(base.DataSession, typeof(ReducedRecipient), this.addressList)); return(ADVlvPagedReader <ReducedRecipient> .GetADVlvPagedReader(this.addressList, (IRecipientSession)base.DataSession, this.InternalSortBy, this.IncludeBookmarkObject, true, this.PageSize, 1, this.BookmarkDisplayName, this.propertiesToRead)); } base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ReducedRecipient), this.InternalFilter, this.RootId, this.DeepSearch)); return(((IRecipientSession)base.DataSession).FindPaged <ReducedRecipient>((ADObjectId)this.RootId, this.DeepSearch ? QueryScope.SubTree : QueryScope.OneLevel, this.InternalFilter, this.InternalSortBy, this.PageSize, this.propertiesToRead)); }
protected override IEnumerable <PolicyStorage> GetPagedData() { QueryFilter internalFilter = this.InternalFilter; base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(PolicyStorage), internalFilter, this.RootId, this.DeepSearch)); IEnumerable <PolicyStorage> source = base.DataSession.FindPaged <PolicyStorage>(internalFilter, this.RootId, this.DeepSearch, this.InternalSortBy, this.PageSize); return(from dataObj in source where dataObj.Scenario == PolicyScenario.DeviceSettings || dataObj.Scenario == PolicyScenario.DeviceConditionalAccess || dataObj.Scenario == PolicyScenario.DeviceTenantConditionalAccess select dataObj); }
private bool LegacyDNIsUnique(string legacyDN) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, legacyDN), new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, this.DataObject.Id) }); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.TenantGlobalCatalogSession, typeof(ADRecipient), filter, null, true)); ADRecipient[] array = base.TenantGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1); return(0 == array.Length); }
protected override IEnumerable <ADContact> GetPagedData() { if (base.ParameterSetName == "CookieSet") { base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADContact), this.InternalFilter, this.RootId, this.DeepSearch)); base.InternalResultSize = Unlimited <uint> .UnlimitedValue; ADPagedReader <ADContact> adpagedReader = (ADPagedReader <ADContact>)base.DataSession.FindPaged <ADContact>(this.InternalFilter, this.RootId, this.DeepSearch, this.InternalSortBy, this.PageSize); adpagedReader.Cookie = this.inputCookie.PageCookie; return(adpagedReader); } return(base.GetPagedData()); }
internal static string GenerateUniqueRoleAssignmentName(IConfigurationSession configurationSession, ADObjectId orgContainerId, string roleName, string roleAssigneeName, RoleAssignmentDelegationType roleAssignmentDelegationType, Task.TaskVerboseLoggingDelegate writeVerbose) { if (configurationSession == null) { throw new ArgumentNullException("configurationSession"); } if (orgContainerId == null) { throw new ArgumentNullException("orgContainerId"); } string text = roleName + "-" + roleAssigneeName; if (roleAssignmentDelegationType != RoleAssignmentDelegationType.Regular) { text += "-Delegating"; } text = text.Trim(); if (text.Length > 64) { text = text.Substring(0, 64).Trim(); } if (writeVerbose == null) { throw new ArgumentNullException("writeVerbose"); } ADObjectId descendantId = orgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer); string text2 = text; if (text2.Length > 61) { text2 = text2.Substring(0, 61).Trim(); } int num = 1; for (;;) { QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, text); writeVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configurationSession, typeof(ExchangeRoleAssignment), filter, descendantId, false)); ExchangeRoleAssignment[] array = configurationSession.Find <ExchangeRoleAssignment>(descendantId, QueryScope.OneLevel, filter, null, 1); if (array.Length == 0) { break; } text = text2 + "-" + num.ToString(); num++; if (num >= 100) { return(text); } } return(text); }
protected override IEnumerable <ADRawEntry> GetPagedData() { if (this.Cookie == null) { DeletedRecipient item = new DeletedRecipient(); return(new List <ADRawEntry> { item }); } PropertyDefinition[] properties = new PropertyDefinition[] { ADObjectSchema.Id, ADObjectSchema.Name, ADObjectSchema.DistinguishedName, ADObjectSchema.Guid, ADObjectSchema.OrganizationalUnitRoot, ADObjectSchema.ObjectClass, ADObjectSchema.WhenChanged, ADObjectSchema.WhenChangedUTC, ADObjectSchema.WhenCreated, ADObjectSchema.WhenCreatedUTC }; if (this.requireTwoQueries) { IRecipientSession sessionForSoftDeletedObjects = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(base.CurrentOrganizationId, this.DomainController); ADObjectId childId = base.CurrentOrganizationId.OrganizationalUnit.GetChildId("OU", "Soft Deleted Objects"); QueryFilter queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.IsSoftDeletedByRemove, true); queryFilter = new AndFilter(new QueryFilter[] { queryFilter, SyncTaskHelper.GetDeltaFilter(this.inputCookie) }); this.reader2 = sessionForSoftDeletedObjects.FindPagedADRawEntry(childId, QueryScope.OneLevel, queryFilter, null, this.PageSize, properties); this.reader2.Cookie = this.inputCookie.PageCookie2; base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(sessionForSoftDeletedObjects, typeof(ADRawEntry), queryFilter, null, false)); } IRecipientSession recipientSession = (IRecipientSession)base.DataSession; ADObjectId deletedObjectsContainer = ADSession.GetDeletedObjectsContainer(recipientSession.GetDomainNamingContext()); QueryFilter internalFilter = this.InternalFilter; recipientSession.SessionSettings.SkipCheckVirtualIndex = true; ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(deletedObjectsContainer, QueryScope.OneLevel, internalFilter, null, this.PageSize, properties); adpagedReader.IncludeDeletedObjects = true; adpagedReader.Cookie = this.inputCookie.PageCookie; base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADRawEntry), this.InternalFilter, null, false)); return(adpagedReader); }
// Token: 0x06001209 RID: 4617 RVA: 0x0003817C File Offset: 0x0003637C internal static Server FindMailboxServer(string domainController, OfflineAddressBook currentOABSettings, LogMessageDelegate logger) { ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController); QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, Server.E14MinVersion), new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL), new ComparisonFilter(ComparisonOperator.Equal, ActiveDirectoryServerSchema.IsExcludedFromProvisioning, false) }); PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(Server), filter, null, true), logger); ADPagedReader <Server> adpagedReader = topologyConfigurationSession.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0); List <Server> list = new List <Server>(); foreach (Server server in adpagedReader) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundMailboxServer(server.Identity.ToString()), logger); list.Add(server); } if (currentOABSettings.Server != null) { Server currentOABServer = topologyConfigurationSession.Read <Server>(currentOABSettings.Server); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOABIsCurrentlyOnServer((currentOABServer == null) ? Strings.VerboseLbDeletedServer : currentOABServer.Identity.ToString()), logger); if (currentOABServer != null && list.Find((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)) != null) { if (list.Count == 1) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOnlyOneEligibleServer(currentOABServer.Identity.ToString()), logger); return(currentOABServer); } list.RemoveAll((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)); } } if (list.Count == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoEligibleServers, logger); return(null); } if (list.Count == 1) { return(list[0]); } Random random = new Random(); Server server2 = list[random.Next(0, list.Count)]; PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbReturningServer(server2.Identity.ToString()), logger); return(server2); }
protected override IConfigurable ResolveDataObject() { TaskLogger.LogEnter(); IConfigurable[] array = null; base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(SmimeConfigurationContainer), this.InternalFilter, this.RootId, this.DeepSearch)); try { array = base.DataSession.Find <SmimeConfigurationContainer>(this.InternalFilter, this.RootId, this.DeepSearch, null); } catch (DataSourceTransientException exception) { base.WriteError(exception, (ErrorCategory)1002, null); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (array == null) { array = new IConfigurable[0]; } IConfigurable result = null; switch (array.Length) { case 0: { SmimeConfigurationContainer smimeConfigurationContainer = new SmimeConfigurationContainer(); smimeConfigurationContainer.SetId(this.RootId as ADObjectId); smimeConfigurationContainer.Initialize(); smimeConfigurationContainer.OrganizationId = base.CurrentOrganizationId; result = smimeConfigurationContainer; break; } case 1: result = array[0]; break; default: TaskLogger.Log(Strings.SmimeConfigAmbiguous); break; } TaskLogger.LogExit(); return(result); }
// Token: 0x0600120A RID: 4618 RVA: 0x00038380 File Offset: 0x00036580 internal static IEnumerable FindVirtualDirectories(string domainController, LogMessageDelegate logger) { ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController); PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(ADOabVirtualDirectory), null, null, true), logger); ADPagedReader <ADOabVirtualDirectory> adpagedReader = topologyConfigurationSession.FindPaged <ADOabVirtualDirectory>(null, QueryScope.SubTree, null, null, 0); List <ComparableEntry <ADOabVirtualDirectory> > list = new List <ComparableEntry <ADOabVirtualDirectory> >(); foreach (ADOabVirtualDirectory adoabVirtualDirectory in adpagedReader) { ServerVersion serverVersion = null; if (adoabVirtualDirectory.Server != null) { serverVersion = Server.GetServerVersion(adoabVirtualDirectory.Server.Name); } if (!(serverVersion == null) && ServerVersion.Compare(serverVersion, PhysicalResourceLoadBalancing.E15MinVersion) >= 0) { list.Add(new ComparableEntry <ADOabVirtualDirectory>(adoabVirtualDirectory) { Count = adoabVirtualDirectory.OfflineAddressBooks.Count }); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundOabVDir(adoabVirtualDirectory.Id.ToDNString(), adoabVirtualDirectory.OfflineAddressBooks.Count), logger); } } list.Sort(); int num = PhysicalResourceLoadBalancing.MaxNumOfVdirs; if (num > list.Count) { num = list.Count; } if (num == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoOabVDirReturned, logger); } List <ADObjectId> list2 = new List <ADObjectId>(num); for (int i = 0; i < num; i++) { list2.Add(list[i].Entry.Id); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOabVDirSelected(list[i].Entry.Id.ToDNString()), logger); } return(list2); }
private bool LegacyDNIsUnique(string legacyDN) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, legacyDN), new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, this.DataObject.Id) }); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.RootOrgGlobalCatalogSession, typeof(ADRecipient), filter, null, true)); ADRecipient[] array = base.RootOrgGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1); bool flag = 0 == array.Length; if (VariantConfiguration.InvariantNoFlightingSnapshot.CmdletInfra.ServiceAccountForest.Enabled && base.CurrentOrganizationId != OrganizationId.ForestWideOrgId) { array = base.PartitionOrRootOrgGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1); flag = (flag && 0 == array.Length); } return(flag); }
private AddressBookBase[] FindAddressList(string name, QueryFilter recipientFilter) { ADObjectId id = this.DataObject.Id; QueryFilter findFilterForCannedAddressLists = CannedAddressListsFilterHelper.GetFindFilterForCannedAddressLists(name, recipientFilter); IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession; base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configurationSession, typeof(AddressBookBase), findFilterForCannedAddressLists, id, false)); AddressBookBase[] result; try { AddressBookBase[] array = configurationSession.Find <AddressBookBase>(id, QueryScope.SubTree, findFilterForCannedAddressLists, null, 1); result = array; } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); } return(result); }
// Token: 0x06001214 RID: 4628 RVA: 0x00038DB8 File Offset: 0x00036FB8 private static Server[] GetMailboxServers(ITopologyConfigurationSession configSession, bool localSiteOnly, LogMessageDelegate logger) { QueryFilter queryFilter = new AndFilter(new QueryFilter[] { new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL), new ComparisonFilter(ComparisonOperator.NotEqual, ActiveDirectoryServerSchema.IsOutOfService, true), new ExistsFilter(ActiveDirectoryServerSchema.HostedDatabaseCopies) }); QueryFilter filter; if (PhysicalResourceLoadBalancing.IsDatacenter) { if (localSiteOnly) { ADSite localSite = configSession.GetLocalSite(); queryFilter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ServerSite, localSite.Id) }); } QueryFilter mailboxServerVersionFilter = PhysicalResourceLoadBalancing.GetMailboxServerVersionFilter(); filter = QueryFilter.AndTogether(new QueryFilter[] { queryFilter, mailboxServerVersionFilter }); } else { filter = queryFilter; } PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(Server), filter, null, false), logger); Server[] array = configSession.Find <Server>(null, QueryScope.SubTree, filter, null, 0); if (array == null || array.Length == 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoServerForDatabaseException("Can not find any available mailbox server."), logger); throw new NoServersForDatabaseException("Can not find any mailbox server in local site"); } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved {0} mailbox servers.", array.Length)), logger); return(array); }
private bool LegacyDNIsUnique(string legacyDN) { QueryFilter filter = new AndFilter(new QueryFilter[] { new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, legacyDN), new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, this.DataObject.Id) }); IRecipientSession recipientSession = RecipientTaskHelper.CreatePartitionOrRootOrgScopedGcSession(base.DomainController, this.DataObject.Id); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(recipientSession, typeof(ADRecipient), filter, null, true)); ADRecipient[] array = null; try { array = recipientSession.Find(null, QueryScope.SubTree, filter, null, 1); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(recipientSession)); } return(0 == array.Length); }
// Token: 0x06001212 RID: 4626 RVA: 0x00038AD8 File Offset: 0x00036CD8 private static List <MailboxDatabase> GetDatabasesOnMailboxServers(ITopologyConfigurationSession configSession, Server[] mailboxServers, LogMessageDelegate logger) { Dictionary <string, MailboxDatabase> allEnabledDatabases = PhysicalResourceLoadBalancing.GetAllEnabledDatabases(configSession, logger); List <MailboxDatabase> list = new List <MailboxDatabase>(); if (allEnabledDatabases.Count > 0) { HashSet <string> hashSet = new HashSet <string>(StringComparer.OrdinalIgnoreCase); foreach (Server server in mailboxServers) { hashSet.Add(server.Name); } QueryFilter filter = new OrFilter(new QueryFilter[] { new NotFilter(new ExistsFilter(DatabaseCopySchema.ParentObjectClass)), new TextFilter(DatabaseCopySchema.ParentObjectClass, MailboxDatabase.MostDerivedClass, MatchOptions.FullString, MatchFlags.IgnoreCase) }); ADObjectId rootId = ProvisioningCache.Instance.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.DatabaseContainerId, new ProvisioningCache.CacheObjectGetterDelegate(configSession.GetDatabasesContainerId)); PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(DatabaseCopy), filter, rootId, false), logger); ADPagedReader <DatabaseCopy> adpagedReader = configSession.FindPaged <DatabaseCopy>(rootId, QueryScope.SubTree, filter, null, 0); int num = 0; foreach (DatabaseCopy databaseCopy in adpagedReader) { MailboxDatabase mailboxDatabase; if (databaseCopy.IsValid && allEnabledDatabases.TryGetValue(databaseCopy.DatabaseName, out mailboxDatabase) && !string.IsNullOrEmpty(mailboxDatabase.ServerName) && hashSet.Contains(mailboxDatabase.ServerName)) { allEnabledDatabases.Remove(databaseCopy.DatabaseName); list.Add(mailboxDatabase); } num++; } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved '{0}' mailbox database copies. '{1}' databases have copies on selected mailbox servers.", num, list.Count)), logger); } if (list.Count <= 0) { PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoDatabaseFoundInAD, logger); } return(list); }
// Token: 0x06001213 RID: 4627 RVA: 0x00038C84 File Offset: 0x00036E84 private static Dictionary <string, MailboxDatabase> GetAllEnabledDatabases(ITopologyConfigurationSession configSession, LogMessageDelegate logger) { ADObjectId adobjectId = ProvisioningCache.Instance.TryAddAndGetGlobalData <ADObjectId>(CannedProvisioningCacheKeys.DatabaseContainerId, new ProvisioningCache.CacheObjectGetterDelegate(configSession.GetDatabasesContainerId)); PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbDatabaseContainer(adobjectId.ToDNString()), logger); List <QueryFilter> list = new List <QueryFilter> { new ComparisonFilter(ComparisonOperator.Equal, MailboxDatabaseSchema.IsExcludedFromProvisioning, false), new ComparisonFilter(ComparisonOperator.Equal, MailboxDatabaseSchema.IsSuspendedFromProvisioning, false), new ComparisonFilter(ComparisonOperator.Equal, DatabaseSchema.Recovery, false) }; QueryFilter filter = QueryFilter.AndTogether(list.ToArray()); PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configSession, typeof(MailboxDatabase), filter, adobjectId, false), logger); ADPagedReader <MailboxDatabase> adpagedReader = configSession.FindPaged <MailboxDatabase>(adobjectId, QueryScope.OneLevel, filter, null, 0); Dictionary <string, MailboxDatabase> dictionary = new Dictionary <string, MailboxDatabase>(); foreach (MailboxDatabase mailboxDatabase in adpagedReader) { dictionary[mailboxDatabase.Name] = mailboxDatabase; } PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbGeneralTrace(string.Format("Retrieved {0} mailbox databases enabled for provisioning in the forest.", dictionary.Count)), logger); return(dictionary); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); base.InternalProcessRecord(); ServerIdParameter serverIdParameter = new ServerIdParameter(); Server server = (Server)base.GetDataObject <Server>(serverIdParameter, base.DataSession, null, new LocalizedString?(Strings.ErrorServerNotFound(serverIdParameter.ToString())), new LocalizedString?(Strings.ErrorServerNotUnique(serverIdParameter.ToString()))); if (!server.IsClientAccessServer && !server.IsCafeServer) { base.ThrowTerminatingError(server.GetServerRoleError(ServerRole.ClientAccess), ErrorCategory.InvalidOperation, server); } using (ServerManager serverManager = new ServerManager()) { ApplicationPool applicationPool = serverManager.ApplicationPools["MSExchangeOWAAppPool"]; if (applicationPool == null) { base.ThrowTerminatingError(new ADNoSuchObjectException(Strings.ErrorOWAVdirAppPoolNotExist), ErrorCategory.ObjectNotFound, serverManager.ApplicationPools); } applicationPool.ManagedPipelineMode = 0; serverManager.CommitChanges(); } QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, ADOwaVirtualDirectorySchema.OwaVersion, OwaVersions.Exchange2003or2000); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADOwaVirtualDirectory), filter, server.Identity, true)); IConfigDataProvider dataSession = base.DataSession; IEnumerable <ADOwaVirtualDirectory> enumerable = dataSession.FindPaged <ADOwaVirtualDirectory>(filter, server.Identity, true, null, 0); foreach (ADOwaVirtualDirectory adowaVirtualDirectory in enumerable) { if (adowaVirtualDirectory.WebSite.Equals("Exchange Back End", StringComparison.OrdinalIgnoreCase)) { string metabasePath = adowaVirtualDirectory.MetabasePath; try { base.WriteVerbose(Strings.VerboseConnectingIISVDir(metabasePath)); using (IisUtility.CreateIISDirectoryEntry(metabasePath)) { if (!DirectoryEntry.Exists(metabasePath)) { this.WriteWarning(Strings.OwaAdOrphanFound(adowaVirtualDirectory.Identity.ToString())); continue; } if (!IisUtility.WebDirObjectExists(metabasePath, this.owaVersion)) { base.WriteVerbose(Strings.VerboseCreatingChildVDir(this.owaVersion, metabasePath)); CreateVirtualDirectory createVirtualDirectory = new CreateVirtualDirectory(); createVirtualDirectory.Name = this.owaVersion; createVirtualDirectory.Parent = metabasePath; createVirtualDirectory.CustomizedVDirProperties = OwaVirtualDirectoryHelper.GetVersionVDirProperties(); createVirtualDirectory.LocalPath = (string)IisUtility.GetIisPropertyValue("Path", createVirtualDirectory.CustomizedVDirProperties); createVirtualDirectory.Initialize(); createVirtualDirectory.Execute(); } } OwaVirtualDirectoryHelper.CreateLegacyVDirs(metabasePath, true); OwaVirtualDirectoryHelper.CreateOwaCalendarVDir(metabasePath, VirtualDirectoryRole.Mailbox); if (ExchangeServiceVDirHelper.IsBackEndVirtualDirectory(adowaVirtualDirectory)) { WebAppVirtualDirectoryHelper.UpdateMetabase(adowaVirtualDirectory, metabasePath, true); } } catch (COMException ex) { base.WriteError(new IISGeneralCOMException(ex.Message, ex.ErrorCode, ex), ErrorCategory.InvalidOperation, null); } if (adowaVirtualDirectory.ExchangeVersion.IsOlderThan(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion)) { try { adowaVirtualDirectory.SetExchangeVersion(adowaVirtualDirectory.MaximumSupportedExchangeObjectVersion); base.DataSession.Save(adowaVirtualDirectory); } catch (DataSourceTransientException exception) { base.WriteError(exception, ErrorCategory.WriteError, null); } } } } TaskLogger.LogExit(); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); Database database = (Database)base.PrepareDataObject(); database.InvalidDatabaseCopiesAllowed = true; if (this.preExistingDatabase != null) { database = this.preExistingDatabase; database.InvalidDatabaseCopiesAllowed = true; TaskLogger.LogExit(); return(database); } base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(PublicFolderDatabase), null, this.OwnerServer.Identity, true)); this.ownerServerPublicFolderDatabases = this.OwnerServer.GetPublicFolderDatabases(); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(Database), null, this.OwnerServer.Identity, true)); this.ownerServerDatabases = this.OwnerServer.GetDatabases(); string logFilePrefix = this.CalculateLogFilePrefix(); database.LogFilePrefix = logFilePrefix; if (null != this.LogFolderPath) { try { this.ValidateLogFolderPath(); } catch (WmiException ex) { Exception exception = new InvalidOperationException(Strings.ErrorFailedToConnectToServer(this.OwnerServer.Name, ex.Message)); ErrorCategory category = ErrorCategory.InvalidOperation; TDataObject dataObject = this.DataObject; base.WriteError(exception, category, dataObject.Identity); } catch (UnauthorizedAccessException ex2) { Exception exception2 = new InvalidOperationException(Strings.ErrorFailedToConnectToServer(this.OwnerServer.Name, ex2.Message)); ErrorCategory category2 = ErrorCategory.InvalidOperation; TDataObject dataObject2 = this.DataObject; base.WriteError(exception2, category2, dataObject2.Identity); } } database.SetId(base.GlobalConfigSession.GetDatabasesContainerId().GetChildId(this.Name)); database.Name = this.Name; database.AdminDisplayName = this.Name; database.Server = (ADObjectId)this.OwnerServer.Identity; TDataObject dataObject3 = this.DataObject; dataObject3.DataMoveReplicationConstraint = DataMoveReplicationConstraintParameter.None; if (this.OwnerServer.DatabaseAvailabilityGroup != null) { database.MasterServerOrAvailabilityGroup = this.OwnerServer.DatabaseAvailabilityGroup; } else { database.MasterServerOrAvailabilityGroup = (ADObjectId)this.OwnerServer.Identity; } string text = new ClientAccessArrayTaskHelper(new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskErrorLoggingDelegate(base.WriteError)).FindRpcClientAccessArrayOrServer((ITopologyConfigurationSession)this.ConfigurationSession, database.Server); if (text != null) { database.RpcClientAccessServerLegacyDN = text; } else { database.RpcClientAccessServerLegacyDN = this.OwnerServer.ExchangeLegacyDN; } TaskLogger.LogExit(); return(database); }
protected override IConfigurable PrepareDataObject() { TaskLogger.LogEnter(); ADDynamicGroup addynamicGroup = (ADDynamicGroup)base.PrepareDataObject(); this.originalFilter = addynamicGroup.RecipientFilter; if (base.Fields.IsModified(DynamicDistributionGroupSchema.RecipientContainer)) { addynamicGroup.RecipientContainer = this.recipientContainerId; } else if (addynamicGroup.IsChanged(DynamicDistributionGroupSchema.RecipientContainer) && addynamicGroup.RecipientContainer != null) { addynamicGroup.RecipientContainer = this.ValidateRecipientContainer(new OrganizationalUnitIdParameter(addynamicGroup.RecipientContainer)); } if (base.Fields.IsModified("ManagedBy")) { addynamicGroup.ManagedBy = ((this.managedBy == null) ? null : this.managedBy.Id); } if (addynamicGroup.ManagedBy != null) { if (this.managedBy == null) { this.managedBy = (ADRecipient)base.GetDataObject <ADRecipient>(new GeneralRecipientIdParameter(addynamicGroup.ManagedBy), base.TenantGlobalCatalogSession, null, new LocalizedString?(Strings.ErrorRecipientNotFound(addynamicGroup.ManagedBy.ToString())), new LocalizedString?(Strings.ErrorRecipientNotUnique(addynamicGroup.ManagedBy.ToString())), ExchangeErrorCategory.Client); } if (!addynamicGroup.OrganizationId.Equals(this.managedBy.OrganizationId)) { base.WriteError(new RecipientTaskException(Strings.ErrorManagedByCrossTenant(this.managedBy.Identity.ToString())), ExchangeErrorCategory.Client, addynamicGroup.Identity); } } if (base.Fields.IsModified("ExpansionServer")) { addynamicGroup.ExpansionServer = this.ExpansionServer; addynamicGroup.HomeMTA = this.homeMTA; } else if (addynamicGroup.IsChanged(DistributionGroupBaseSchema.ExpansionServer)) { if (!string.IsNullOrEmpty(addynamicGroup.ExpansionServer)) { QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ExchangeLegacyDN, addynamicGroup.ExpansionServer); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(Server), filter, null, true)); Server[] array = null; try { array = base.GlobalConfigSession.Find <Server>(null, QueryScope.SubTree, filter, null, 2); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.GlobalConfigSession)); } switch (array.Length) { case 0: base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorServerNotFound(addynamicGroup.ExpansionServer)), ExchangeErrorCategory.Client, this.Identity); return(null); case 1: base.ValidateExpansionServer(array[0], false); addynamicGroup.ExpansionServer = array[0].ExchangeLegacyDN; break; case 2: base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorServerNotUnique(addynamicGroup.ExpansionServer)), ExchangeErrorCategory.Client, this.Identity); return(null); } addynamicGroup.HomeMTA = array[0].ResponsibleMTA; } else { addynamicGroup.HomeMTA = null; } } if (base.Fields.IsModified(DynamicDistributionGroupSchema.RecipientFilter)) { addynamicGroup.SetRecipientFilter(this.innerFilter); } addynamicGroup.RecipientDisplayType = new RecipientDisplayType?(RecipientDisplayType.DynamicDistributionGroup); TaskLogger.LogExit(); return(addynamicGroup); }
internal bool ObjectExists <T>(IConfigDataProvider session, QueryFilter filter) where T : ADConfigurationObject, new() { this.writeVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(session, typeof(T), filter, null, true)); return(session.Find <T>(filter, null, true, null).Length > 0); }
public void CreatePublicFolderTree() { this.pfTree = new PublicFolderTree(); try { QueryFilter filter; ADObjectId adobjectId; if (Datacenter.GetExchangeSku() != Datacenter.ExchangeSku.ExchangeDatacenter) { filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, PublicFolderTreeContainer.DefaultName); PublicFolderTreeContainer[] array = this.taskInstance.GlobalConfigSession.Find <PublicFolderTreeContainer>(null, QueryScope.SubTree, filter, null, 1); PublicFolderTreeContainer publicFolderTreeContainer; if (array == null || array.Length == 0) { filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, AdministrativeGroup.DefaultName); AdministrativeGroup[] array2 = this.taskInstance.GlobalConfigSession.Find <AdministrativeGroup>(null, QueryScope.SubTree, filter, null, 1); if (array2 == null || array2.Length < 1) { throw new AdminGroupNotFoundException(AdministrativeGroup.DefaultName); } publicFolderTreeContainer = new PublicFolderTreeContainer(); publicFolderTreeContainer.SetId(array2[0].Id.GetChildId(PublicFolderTreeContainer.DefaultName)); this.taskInstance.DataSession.Save(publicFolderTreeContainer); } else { publicFolderTreeContainer = array[0]; } adobjectId = publicFolderTreeContainer.Id; } else { adobjectId = this.OrganizationId.ConfigurationUnit; this.pfTree.OrganizationId = this.OrganizationId; } this.pfTree.SetId(adobjectId.GetChildId("Public Folders")); this.taskInstance.WriteVerbose(Strings.VerboseCreatePublicFolderTree(this.pfTree.Id.ToString())); this.pfTree.PublicFolderTreeType = PublicFolderTreeType.Mapi; filter = new ComparisonFilter(ComparisonOperator.Equal, ExtendedRightSchema.DisplayName, "Create public folder"); this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(this.taskInstance.GlobalConfigSession, typeof(ExtendedRight), filter, this.taskInstance.GlobalConfigSession.ConfigurationNamingContext, true)); ExtendedRight[] array3 = this.taskInstance.GlobalConfigSession.Find <ExtendedRight>(this.taskInstance.GlobalConfigSession.ConfigurationNamingContext, QueryScope.SubTree, filter, null, 1); if (0 < array3.Length) { ObjectAce objectAce = new ObjectAce(AceFlags.None, AceQualifier.AccessAllowed, 256, new SecurityIdentifier("AU"), ObjectAceFlags.ObjectAceTypePresent, array3[0].RightsGuid, Guid.Empty, false, null); DiscretionaryAcl discretionaryAcl = new DiscretionaryAcl(false, true, 11); discretionaryAcl.AddAccess(AccessControlType.Allow, objectAce.SecurityIdentifier, objectAce.AccessMask, objectAce.InheritanceFlags, objectAce.PropagationFlags, objectAce.ObjectAceFlags, objectAce.ObjectAceType, objectAce.InheritedObjectAceType); using (WindowsIdentity current = WindowsIdentity.GetCurrent()) { SecurityIdentifier user = current.User; CommonSecurityDescriptor commonSecurityDescriptor = new CommonSecurityDescriptor(false, true, ControlFlags.DiscretionaryAclPresent, user, user, null, discretionaryAcl); byte[] binaryForm = new byte[commonSecurityDescriptor.BinaryLength]; commonSecurityDescriptor.GetBinaryForm(binaryForm, 0); this.pfTree.SetPublicFolderDefaultAdminAcl(new RawSecurityDescriptor(binaryForm, 0)); } } this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.TenantSession)); this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.pfTree, this.TenantSession, typeof(PublicFolderTree))); this.TenantSession.Save(this.pfTree); if (Datacenter.GetExchangeSku() == Datacenter.ExchangeSku.ExchangeDatacenter) { this.SetOrganizationManagementACLs(this.pfTree); } } finally { this.taskInstance.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.TenantSession)); } }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (base.HasErrors) { return; } DistributionGroupTaskHelper.CheckMembershipRestriction(this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError)); if (this.RoomList.IsPresent && this.DataObject.RecipientTypeDetails != RecipientTypeDetails.RoomList) { this.ValidateConvertToRoomList(); } base.ValidateMultiReferenceParameter(DistributionGroupSchema.ManagedBy, new ValidateRecipientWithBaseObjectDelegate <ADGroup>(MailboxTaskHelper.ValidateGroupManagedBy)); MultiValuedProperty <ADRecipient> recipients; this.recipientsDictionary.TryGetValue(DistributionGroupSchema.ManagedBy, out recipients); if (base.Fields.IsModified(DistributionGroupSchema.ManagedBy) || base.Fields.IsModified(DistributionGroupSchema.MemberJoinRestriction) || base.Fields.IsModified(DistributionGroupSchema.MemberDepartRestriction) || this.DataObject.ModerationEnabled || base.Fields.IsModified(MailEnabledRecipientSchema.ModeratedBy)) { MailboxTaskHelper.ValidateGroupManagedByRecipientRestriction(base.TenantGlobalCatalogSession, this.DataObject, recipients, new DataAccessHelper.CategorizedGetDataObjectDelegate(base.GetDataObject <ADRecipient>), new Task.ErrorLoggerDelegate(base.WriteError), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } if (this.DataObject.IsModified(ADMailboxRecipientSchema.SamAccountName)) { RecipientTaskHelper.IsSamAccountNameUnique(this.DataObject, this.DataObject.SamAccountName, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.ErrorLoggerDelegate(base.WriteError), ExchangeErrorCategory.Client); } if (base.Fields.IsModified("ExpansionServer")) { this.DataObject.ExpansionServer = this.ExpansionServer; this.DataObject.HomeMTA = this.homeMTA; } else if (this.DataObject.IsChanged(DistributionGroupBaseSchema.ExpansionServer)) { if (!string.IsNullOrEmpty(this.DataObject.ExpansionServer)) { QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ServerSchema.ExchangeLegacyDN, this.DataObject.ExpansionServer); base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(Server), filter, null, true)); Server[] array = null; try { array = base.GlobalConfigSession.Find <Server>(null, QueryScope.SubTree, filter, null, 2); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.GlobalConfigSession)); } switch (array.Length) { case 0: base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorServerNotFound(this.DataObject.ExpansionServer)), ExchangeErrorCategory.Client, this.Identity); return; case 1: base.ValidateExpansionServer(array[0], false); this.DataObject.ExpansionServer = array[0].ExchangeLegacyDN; break; case 2: base.WriteError(new ManagementObjectAmbiguousException(Strings.ErrorServerNotUnique(this.DataObject.ExpansionServer)), ExchangeErrorCategory.Client, this.Identity); return; } this.DataObject.HomeMTA = array[0].ResponsibleMTA; } else { this.DataObject.HomeMTA = null; } } DistributionGroupTaskHelper.CheckModerationInMixedEnvironment(this.DataObject, new Task.TaskWarningLoggingDelegate(this.WriteWarning), Strings.WarningLegacyExchangeServer); TaskLogger.LogExit(); }