protected void PostExchange(ADObjectId alContainer) { IConfigurationSession configurationSession = base.CreateGlobalWritableConfigSession(); bool skipRangedAttributes = configurationSession.SkipRangedAttributes; configurationSession.SkipRangedAttributes = true; try { ExchangeConfigurationContainerWithAddressLists exchangeConfigurationContainerWithAddressLists = configurationSession.GetExchangeConfigurationContainerWithAddressLists(); if (exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent()) { exchangeConfigurationContainerWithAddressLists.AddressBookRoots2.Add(alContainer); } base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer))); configurationSession.Save(exchangeConfigurationContainerWithAddressLists); exchangeConfigurationContainerWithAddressLists.ResetChangeTracking(); if (!AddressBookUtilities.IsTenantAddressList(configurationSession, alContainer)) { exchangeConfigurationContainerWithAddressLists.AddressBookRoots.Add(alContainer); base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer))); configurationSession.Save(exchangeConfigurationContainerWithAddressLists); } } finally { configurationSession.SkipRangedAttributes = skipRangedAttributes; base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); } }
private void SaveObject(ADConfigurationObject dataObject) { try { if (dataObject.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(dataObject, this.configurationSession, dataObject.GetType())); } using (TaskPerformanceData.SaveResult.StartRequestTimer()) { this.configurationSession.Save(dataObject); } } catch (DataSourceTransientException exception) { base.WriteError(exception, (ErrorCategory)1002, null); } finally { if (dataObject.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.configurationSession)); } } }
private void PostOrganization(ADObjectId resAl) { IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession; Organization organization = (base.Organization != null) ? configurationSession.Read <ExchangeConfigurationUnit>(base.CurrentOrgContainerId) : configurationSession.Read <Organization>(configurationSession.GetOrgContainerId()); ADObjectId deletedObjectsContainer = configurationSession.DeletedObjectsContainer; List <ADObjectId> list = new List <ADObjectId>(); foreach (ADObjectId adobjectId in organization.ResourceAddressLists) { if (adobjectId.Parent.Equals(deletedObjectsContainer)) { list.Add(adobjectId); } } foreach (ADObjectId item in list) { organization.ResourceAddressLists.Remove(item); } organization.ResourceAddressLists.Add(resAl); base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(organization, configurationSession, typeof(Organization))); try { configurationSession.Save(organization); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.RootId, this.DataObject }); try { base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.dataObject.Identity, base.DataSession, typeof(TDataObject))); base.DataSession.Delete(this.dataObject); } catch (DataSourceTransientException exception) { base.WriteError(exception, ErrorCategory.WriteError, null); } catch (NullReferenceException innerException) { LocalizedException exception2 = new LocalizedException(Strings.ExceptionRemoveNoneExistenceObject, innerException); base.WriteError(exception2, ErrorCategory.WriteError, null); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } TaskLogger.LogExit(); }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); this.nonAtomicTagObject = this.DataObject; base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(this.DataObject.Identity, base.DataSession, typeof(RetentionPolicyTag))); RetentionPolicyTag retentionPolicyTag = null; try { IConfigurationSession configurationSession = base.DataSession as IConfigurationSession; configurationSession.SessionSettings.IsSharedConfigChecked = true; retentionPolicyTag = configurationSession.Read <RetentionPolicyTag>(this.DataObject.Id); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (retentionPolicyTag == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(this.DataObject.Identity), typeof(RetentionPolicyTag).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, this.DataObject.Identity); } IConfigurationSession session = base.DataSession as IConfigurationSession; this.MakeContentSettingUniqueAndSave(session, this.DataObject, this.contentSettingsObject, this.contentSettingsObject.Name); this.nonAtomicTagObject = null; PresentationRetentionPolicyTag result = new PresentationRetentionPolicyTag(retentionPolicyTag, this.contentSettingsObject); this.WriteResult(result); TaskLogger.LogExit(); }
private void CreateCannedSystemAddressLists(IConfigurationSession session, AddressBookBase parent, out Dictionary <string, bool> addressListsCreated) { addressListsCreated = new Dictionary <string, bool>(); foreach (string text in CannedSystemAddressLists.RecipientFilters.Keys) { AddressBookBase addressBookBase = session.Read <AddressBookBase>(parent.Id.GetChildId(text)); bool flag = false; bool flag2 = false; if (addressBookBase == null) { flag = true; addressBookBase = new AddressBookBase(); addressBookBase.SetId(parent.Id.GetChildId(text)); addressBookBase.DisplayName = text; addressBookBase.OrganizationId = parent.OrganizationId; addressBookBase.IsSystemAddressList = CannedSystemAddressLists.SystemFlags[text]; } if (flag || !string.Equals(LdapFilterBuilder.LdapFilterFromQueryFilter(CannedSystemAddressLists.RecipientFilters[text]), addressBookBase.LdapRecipientFilter, StringComparison.OrdinalIgnoreCase)) { flag2 = true; addressBookBase.SetRecipientFilter(CannedSystemAddressLists.RecipientFilters[text]); addressBookBase[AddressBookBaseSchema.RecipientFilterFlags] = RecipientFilterableObjectFlags.FilterApplied; base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, session, typeof(AddressBookBase))); try { session.Save(addressBookBase); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(session)); } } addressListsCreated.Add(text, flag || flag2); } }
private void RenameAllGroupsAddressListToAllDistributionLists() { AddressBookBase[] array = this.FindAddressList(CannedAddressListsFilterHelper.DefaultAllDistributionLists, CannedAddressListsFilterHelper.DefaultAllDistributionListsFilter); if (array == null || array.Length == 0) { return; } AddressBookBase addressBookBase = array[0]; bool flag = false; if (string.Equals(addressBookBase.DisplayName, Strings.DefaultAllGroups, StringComparison.CurrentCultureIgnoreCase)) { addressBookBase.DisplayName = Strings.DefaultAllDistributionLists; flag = true; } if (string.Equals(addressBookBase.Name, Strings.DefaultAllGroups, StringComparison.CurrentCultureIgnoreCase)) { addressBookBase.Name = Strings.DefaultAllDistributionLists; flag = true; } if (flag) { try { base.DataSession.Save(addressBookBase); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } }
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(); }
private void RemoveMailUser() { if (this.mailUser == null) { this.WriteWarning(Strings.WarningJournalArchiveMailboxHasNoMailUser); return; } if (DisableJournalArchiving.ShouldSoftDeleteUser(this.mailUser)) { SoftDeletedTaskHelper.UpdateRecipientForSoftDelete(base.DataSession as IRecipientSession, this.mailUser, false); SoftDeletedTaskHelper.UpdateExchangeGuidForMailEnabledUser(this.mailUser); this.mailUser.JournalArchiveAddress = SmtpAddress.NullReversePath; base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.mailUser.Identity, base.DataSession, typeof(ADUser))); try { try { RecipientTaskHelper.CreateSoftDeletedObjectsContainerIfNecessary(this.mailUser.Id.Parent, base.DomainController); base.DataSession.Save(this.mailUser); } catch (DataSourceTransientException exception) { base.WriteError(exception, ExchangeErrorCategory.ServerTransient, null); } return; } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } base.WriteError(new RecipientTaskException(Strings.ErrorDisableJournalArchiveMailuserNotSoftDeleted), ExchangeErrorCategory.Client, this.mailUser.Identity); }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); ConsumerMailbox consumerMailbox = null; NetID netID = (NetID)base.Fields[ADUserSchema.NetID]; try { using (TaskPerformanceData.ReadResult.StartRequestTimer()) { ADUser aduser = ConsumerMailboxHelper.ReadUser((IRecipientSession)base.DataSession, netID.ToUInt64(), false); if (aduser != null) { consumerMailbox = new ConsumerMailbox(aduser); } } } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (consumerMailbox == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(netID.ToString(), typeof(ConsumerMailbox).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, netID.ToString()); } using (TaskPerformanceData.WriteResult.StartRequestTimer()) { this.WriteResult(consumerMailbox); } TaskLogger.LogExit(); }
protected void RemoveSystemMailbox() { TDataObject dataObject = base.DataObject; ADObjectId adobjectId = ((ADObjectId)dataObject.Identity).DomainId; adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects"); adobjectId = adobjectId.GetChildId("SystemMailbox" + dataObject.Guid.ToString("B")); try { string identity = adobjectId.ToDNString(); GeneralMailboxIdParameter generalMailboxIdParameter = GeneralMailboxIdParameter.Parse(identity); base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(generalMailboxIdParameter, this.RecipientSessionForSystemMailbox, typeof(ADRecipient), null)); IEnumerable <ADSystemMailbox> objects = generalMailboxIdParameter.GetObjects <ADSystemMailbox>(null, this.RecipientSessionForSystemMailbox); using (IEnumerator <ADSystemMailbox> enumerator = objects.GetEnumerator()) { if (enumerator.MoveNext()) { ADSystemMailbox adsystemMailbox = enumerator.Current; base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.RecipientSessionForSystemMailbox)); base.WriteVerbose(Strings.VerboseDeleteSystemAttendantObject(adsystemMailbox.Identity.ToString())); this.RecipientSessionForSystemMailbox.Delete(adsystemMailbox); } } } catch (DataSourceTransientException ex) { TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[] { dataObject.Identity.ToString(), ex.Message }); this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex.Message)); } catch (DataSourceOperationException ex2) { TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[] { dataObject.Identity.ToString(), ex2.Message }); this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex2.Message)); } catch (DataValidationException ex3) { TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' raises exception: {1}.", new object[] { dataObject.Identity.ToString(), ex3.Message }); this.WriteWarning(Strings.ErrorFailedToRemoveSystemMailbox(dataObject.Identity.ToString(), ex3.Message)); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(this.RecipientSessionForSystemMailbox)); } TaskLogger.Trace("The action of Removing system mailbox object of database '{0}' succeeded.", new object[] { dataObject.Identity.ToString() }); }
public TransportRule Initialize(IConfigDataProvider dataSession, DataClassificationIdParameter identity, OptionalIdentityData optionalData) { ArgumentValidator.ThrowIfNull("dataSession", dataSession); ArgumentValidator.ThrowIfNull("identity", identity); identity.ShouldIncludeOutOfBoxCollections = false; this.task.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(identity, dataSession, typeof(TransportRule), null)); IEnumerable <TransportRule> enumerable = null; try { LocalizedString?localizedString; enumerable = identity.GetObjects <TransportRule>(null, dataSession, optionalData, out localizedString); } finally { this.task.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(dataSession)); } string[] array = new string[] { identity.DataClassificationIdentity }; List <QueryMatchResult> list = new List <QueryMatchResult>(); foreach (TransportRule transportRule in enumerable) { XDocument rulePackXDoc; if (this.TryParseADRulePack(transportRule, out rulePackXDoc) && XmlProcessingUtils.IsFingerprintRuleCollection(rulePackXDoc)) { List <QueryMatchResult> list2 = XmlProcessingUtils.GetMatchingRulesById(rulePackXDoc, array).ToList <QueryMatchResult>(); if (list2.Count == 0) { list2 = XmlProcessingUtils.GetMatchingRulesByName(rulePackXDoc, array, NameMatchingOptions.InvariantNameOrLocalizedNameMatch, true).ToList <QueryMatchResult>(); } list.AddRange(list2); if (list.Count == 1) { this.adRulePack = transportRule; this.ruleXElement = list[0].MatchingRuleXElement; this.ruleResourceXElement = list[0].MatchingResourceXElement; this.rulePackXDocument = this.ruleXElement.Document; ClassificationRuleCollectionPresentationObject rulePackPresentationObject = ClassificationRuleCollectionPresentationObject.Create(this.adRulePack, this.rulePackXDocument); this.DataClassificationPresentationObject = DataClassificationPresentationObject.Create(list[0].MatchingRuleId, list[0].MatchingRuleXElement, list[0].MatchingResourceXElement, rulePackPresentationObject); } else if (list.Count > 1) { break; } } } if (list.Count <= 0) { throw new ManagementObjectNotFoundException(Strings.ErrorCannotFindFingerprintDataClassification(identity.ToString())); } if (list.Count > 1) { throw new ManagementObjectAmbiguousException(Strings.ErrorManagementObjectAmbiguous(identity.ToString())); } return(this.adRulePack); }
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); }
private void CreateCannedAddressList(string name, QueryFilter recipientFilter) { bool flag = string.Equals(name, CannedAddressListsFilterHelper.DefaultAllModernGroups, StringComparison.InvariantCulture); if (flag && (!this.CreateModernGroupsAddressList.IsPresent || !VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).CmdletInfra.InstallModernGroupsAddressList.Enabled)) { return; } ADObjectId id = this.DataObject.Id; AddressBookBase[] array = this.FindAddressList(name, recipientFilter); if (array == null || array.Length == 0) { AddressBookBase addressBookBase = new AddressBookBase(); string text = name; if (flag) { text = Strings.DefaultAllGroups; addressBookBase.IsModernGroupsAddressList = true; } ADObjectId childId = id.GetChildId(text); addressBookBase.SetId(childId); addressBookBase.DisplayName = text; addressBookBase.SetRecipientFilter(recipientFilter); RecipientFilterHelper.StampE2003FilterMetadata(addressBookBase, addressBookBase.LdapRecipientFilter, AddressBookBaseSchema.PurportedSearchUI); addressBookBase.OrganizationId = (base.CurrentOrganizationId ?? OrganizationId.ForestWideOrgId); base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, base.DataSession, typeof(AddressBookBase))); try { base.DataSession.Save(addressBookBase); if (string.Equals(name, CannedAddressListsFilterHelper.DefaultAllRooms, StringComparison.InvariantCulture)) { this.PostOrganization(childId); } } catch (ADObjectAlreadyExistsException) { base.WriteVerbose(Strings.VerboseCannedAddressListAlreadyExists(name)); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } base.WriteObject(addressBookBase); } }
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); }
protected override void InternalEndProcessing() { TaskLogger.LogEnter(); this.PrepareDataObjectToSave(); if (this.objectToSave != null) { try { this.PreSaveValidate(this.objectToSave); if (base.HasErrors) { return; } if (this.objectToSave.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.objectToSave, base.DataSession, typeof(ComplianceJob))); } base.DataSession.Save(this.objectToSave); this.DataObject = this.objectToSave; if (!base.HasErrors) { this.WriteResult(); } } catch (SqlException exception) { base.WriteError(exception, ErrorCategory.WriteError, null); } catch (ArgumentException exception2) { base.WriteError(exception2, ErrorCategory.WriteError, null); } finally { if (this.objectToSave.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } } base.InternalEndProcessing(); TaskLogger.LogExit(); }
private void CreateDefaultGal(ADObjectId defaultGal) { AddressBookBase addressBookBase = new AddressBookBase(); addressBookBase.SetId(defaultGal); addressBookBase.DisplayName = defaultGal.Name; addressBookBase.SetRecipientFilter(GlobalAddressList.RecipientFilterForDefaultGal); addressBookBase[AddressBookBaseSchema.RecipientFilterFlags] = (RecipientFilterableObjectFlags.FilterApplied | RecipientFilterableObjectFlags.IsDefault); RecipientFilterHelper.StampE2003FilterMetadata(addressBookBase, addressBookBase.LdapRecipientFilter, AddressBookBaseSchema.PurportedSearchUI); addressBookBase.OrganizationId = (base.CurrentOrganizationId ?? OrganizationId.ForestWideOrgId); base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(addressBookBase, base.DataSession, typeof(AddressBookBase))); try { base.DataSession.Save(addressBookBase); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } base.WriteObject(addressBookBase); }
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); }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(this.DataObject.Identity, base.DataSession, typeof(RoleGroup))); ADGroup adgroup = null; try { adgroup = (ADGroup)base.DataSession.Read <ADGroup>(this.DataObject.Identity); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (adgroup == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.ResolveIdentityString(this.DataObject.Identity), typeof(RoleGroup).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, this.DataObject.Identity); } Result <ExchangeRoleAssignment>[] array = null; if (this.roleAssignments != null) { array = new Result <ExchangeRoleAssignment> [this.roleAssignments.Count]; for (int i = 0; i < this.roleAssignments.Count; i++) { array[i] = new Result <ExchangeRoleAssignment>(this.roleAssignments[i], null); } } if (null != adgroup.ForeignGroupSid) { adgroup.LinkedGroup = SecurityPrincipalIdParameter.GetFriendlyUserName(adgroup.ForeignGroupSid, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose)); adgroup.ResetChangeTracking(); } RoleGroup result = new RoleGroup(adgroup, array); base.WriteResult(result); TaskLogger.LogExit(); }
private void UpdateTheAllUsersAddressList() { AddressBookBase[] array = this.FindAddressList(CannedAddressListsFilterHelper.DefaultAllUsers, CannedAddressListsFilterHelper.DefaultAllUsersFilter); if (array == null || array.Length == 0) { return; } AddressBookBase addressBookBase = array[0]; if (!object.Equals(addressBookBase.RecipientFilter, CannedAddressListsFilterHelper.DefaultAllUsersFilter)) { addressBookBase.SetRecipientFilter(CannedAddressListsFilterHelper.DefaultAllUsersFilter); try { base.DataSession.Save(addressBookBase); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } }
protected override void InternalEndProcessing() { foreach (AddRemoveManagementRoleEntryActionBase.RoleAndSession roleAndSession in this.roleAndSessionCache.Values) { LocalizedException ex = null; try { if (roleAndSession.Role.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(roleAndSession.Role, roleAndSession.ConfigSession, typeof(ExchangeRole))); } roleAndSession.Role.ApplyChangesToDownlevelData(roleAndSession.ParentRole ?? roleAndSession.Role); roleAndSession.ConfigSession.Save(roleAndSession.Role); } catch (ADOperationException ex2) { ex = ex2; } catch (DataSourceTransientException ex3) { ex = ex3; } finally { if (roleAndSession.Role.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(roleAndSession.ConfigSession)); } } if (ex != null) { foreach (AddRemoveManagementRoleEntryActionBase.PipelinedElement pipelinedElement in roleAndSession.PipelinedElements) { this.WriteError(this.GetRoleSaveException(pipelinedElement.RoleEntryString, roleAndSession.Role.Id.ToString(), ex.Message), ErrorCategory.WriteError, pipelinedElement.ObjectIndex, false); } } } base.InternalEndProcessing(); }
private void PostExchange(ADObjectId defaultGal) { IConfigurationSession configurationSession = base.CreateGlobalWritableConfigSession(); bool skipRangedAttributes = configurationSession.SkipRangedAttributes; configurationSession.SkipRangedAttributes = true; try { ExchangeConfigurationContainerWithAddressLists exchangeConfigurationContainerWithAddressLists = configurationSession.GetExchangeConfigurationContainerWithAddressLists(); if (exchangeConfigurationContainerWithAddressLists.LinkedAddressBookRootAttributesPresent()) { exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList2.Add(defaultGal); } base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer))); configurationSession.Save(exchangeConfigurationContainerWithAddressLists); exchangeConfigurationContainerWithAddressLists.ResetChangeTracking(); if (!AddressBookUtilities.IsTenantAddressList(configurationSession, defaultGal)) { try { exchangeConfigurationContainerWithAddressLists.DefaultGlobalAddressList.Add(defaultGal); base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeConfigurationContainerWithAddressLists, configurationSession, typeof(ExchangeConfigurationContainer))); configurationSession.Save(exchangeConfigurationContainerWithAddressLists); } catch (AdminLimitExceededException innerException) { throw new ADOperationException(Strings.ErrorTooManyGALsCreated, innerException); } } } finally { configurationSession.SkipRangedAttributes = skipRangedAttributes; base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); } }
protected override void WriteResult() { TaskLogger.LogEnter(new object[] { this.DataObject.Identity }); base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(this.DataObject.Identity, base.DataSession, typeof(TransactionalRequestJob))); IConfigurable configurable = null; try { try { configurable = base.DataSession.Read <TransactionalRequestJob>(this.DataObject.Identity); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } if (configurable == null) { base.WriteError(new ManagementObjectNotFoundException(base.GetErrorMessageObjectNotFound(this.DataObject.Identity.ToString(), typeof(TRequest).ToString(), (base.DataSession != null) ? base.DataSession.Source : null)), (ErrorCategory)1003, this.DataObject.Identity); } this.WriteResult(configurable); } finally { IDisposable disposable = configurable as IDisposable; if (disposable != null) { disposable.Dispose(); configurable = null; } } TaskLogger.LogExit(); }
internal static ADSystemMailbox SaveSystemMailbox(MailboxDatabase mdb, Server owningServer, ADObjectId rootOrgContainerId, ITopologyConfigurationSession configSession, IRecipientSession recipientSession, ADObjectId[] forcedReplicationSites, Task.TaskWarningLoggingDelegate writeWarning, Task.TaskVerboseLoggingDelegate writeVerbose) { TaskLogger.LogEnter(); bool useConfigNC = configSession.UseConfigNC; bool useGlobalCatalog = configSession.UseGlobalCatalog; string text = "SystemMailbox" + mdb.Guid.ToString("B"); SecurityIdentifier securityIdentifier = new SecurityIdentifier("SY"); ADSystemMailbox adsystemMailbox = new ADSystemMailbox(); adsystemMailbox.StampPersistableDefaultValues(); adsystemMailbox.Name = text; adsystemMailbox.DisplayName = text; adsystemMailbox.Alias = text; adsystemMailbox.HiddenFromAddressListsEnabled = true; adsystemMailbox.Database = mdb.Id; if (owningServer == null) { throw new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString())); } adsystemMailbox.ServerLegacyDN = owningServer.ExchangeLegacyDN; adsystemMailbox.ExchangeGuid = Guid.NewGuid(); AcceptedDomain defaultAcceptedDomain = configSession.GetDefaultAcceptedDomain(); if (defaultAcceptedDomain == null || defaultAcceptedDomain.DomainName == null || defaultAcceptedDomain.DomainName.Domain == null) { throw new ManagementObjectNotFoundException(Strings.ErrorNoDefaultAcceptedDomainFound(mdb.Identity.ToString())); } adsystemMailbox.EmailAddresses.Add(ProxyAddress.Parse("SMTP:" + adsystemMailbox.Alias + "@" + defaultAcceptedDomain.DomainName.Domain.ToString())); adsystemMailbox.WindowsEmailAddress = adsystemMailbox.PrimarySmtpAddress; adsystemMailbox.SendModerationNotifications = TransportModerationNotificationFlags.Never; Organization organization = configSession.Read <Organization>(rootOrgContainerId); if (organization == null) { throw new ManagementObjectNotFoundException(Strings.ErrorOrganizationNotFound(rootOrgContainerId.Name)); } string parentLegacyDN = string.Format(CultureInfo.InvariantCulture, "{0}/ou={1}/cn=Recipients", new object[] { organization.LegacyExchangeDN, configSession.GetAdministrativeGroupId().Name }); adsystemMailbox.LegacyExchangeDN = LegacyDN.GenerateLegacyDN(parentLegacyDN, adsystemMailbox); ADComputer adcomputer; try { configSession.UseConfigNC = false; configSession.UseGlobalCatalog = true; adcomputer = configSession.FindComputerByHostName(owningServer.Name); } finally { configSession.UseConfigNC = useConfigNC; configSession.UseGlobalCatalog = useGlobalCatalog; } if (adcomputer == null) { throw new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mdb.Identity.ToString())); } ADObjectId adobjectId = adcomputer.Id.DomainId; adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects"); adsystemMailbox.SetId(adobjectId.GetChildId(text)); GenericAce[] aces = new GenericAce[] { new CommonAce(AceFlags.None, AceQualifier.AccessAllowed, 131075, securityIdentifier, false, null) }; DirectoryCommon.SetAclOnAlternateProperty(adsystemMailbox, aces, ADSystemAttendantMailboxSchema.ExchangeSecurityDescriptor, securityIdentifier, securityIdentifier); recipientSession.LinkResolutionServer = mdb.OriginatingServer; bool enforceDefaultScope = recipientSession.EnforceDefaultScope; try { writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox))); recipientSession.EnforceDefaultScope = false; recipientSession.Save(adsystemMailbox); } catch (ADConstraintViolationException ex) { IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ex.Server, false, ConsistencyMode.PartiallyConsistent, configSession.SessionSettings, 705, "SaveSystemMailbox", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\database\\NewMailboxDatabase.cs"); if (!tenantOrTopologyConfigurationSession.ReplicateSingleObjectToTargetDC(mdb, ex.Server)) { throw; } writeVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(adsystemMailbox, recipientSession, typeof(ADSystemMailbox))); recipientSession.Save(adsystemMailbox); } finally { writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(recipientSession)); recipientSession.EnforceDefaultScope = enforceDefaultScope; } if (forcedReplicationSites != null) { DagTaskHelper.ForceReplication(recipientSession, adsystemMailbox, forcedReplicationSites, mdb.Name, writeWarning, writeVerbose); } TaskLogger.LogExit(); return(adsystemMailbox); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); bool flag = base.Fields.Contains("SoftDeletedObject"); if (base.IsVerboseOn) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.DataObject, base.DataSession, typeof(ADUser))); } if (this.WindowsLiveID != null && this.DataObject.NetID == null) { base.WriteError(new RecipientTaskException(Strings.ErrorMissingWindowsLiveIdHandler), ExchangeErrorCategory.ServerOperation, null); } try { if (base.IsDebugOn) { base.WriteDebug(Strings.DebugStartSaveDataObject); } base.DataSession.Save(this.DataObject); if (base.IsDebugOn) { base.WriteDebug(Strings.DebugEndSaveDataObject); } } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } bool flag2 = false; try { if (!flag) { this.StampChangesBeforeSettingPassword(); if (this.IsSetRandomPassword) { base.WriteVerbose(Strings.VerboseSettingPassword(this.DataObject.Id.ToString())); MailboxTaskHelper.SetMailboxPassword((IRecipientSession)base.DataSession, this.DataObject, null, new Task.ErrorLoggerDelegate(base.WriteError)); } else if (this.Password != null) { base.WriteVerbose(Strings.VerboseSettingPassword(this.DataObject.Id.ToString())); ((IRecipientSession)base.DataSession).SetPassword(this.DataObject, this.Password); } bool flag3 = base.Fields.IsModified(ADUserSchema.PasswordLastSetRaw) ? this.ResetPasswordOnNextLogon : this.DataObject.ResetPasswordOnNextLogon; bool bypassModerationCheck = this.DataObject.BypassModerationCheck; ADObjectId id = this.DataObject.Id; using (new CmdletMonitoredScope(base.CurrentTaskContext.UniqueId, "BizLogic", "DataSession.Read<ADUser>", LoggerHelper.CmdletPerfMonitors)) { this.DataObject = (ADUser)base.DataSession.Read <ADUser>(this.DataObject.Identity); } if (this.DataObject == null || this.DataObject.Id == null) { string id2 = (id == null) ? string.Empty : id.ToString(); base.WriteError(new RecipientTaskException(Strings.ErrorCreatedUserNotExist(id2)), ExchangeErrorCategory.ServerOperation, null); } this.DataObject.BypassModerationCheck = bypassModerationCheck; this.DataObject[ADUserSchema.PasswordLastSetRaw] = new long?(flag3 ? 0L : -1L); this.StampChangesAfterSettingPassword(); } base.InternalProcessRecord(); flag2 = !base.HasErrors; } finally { if (!flag2 && this.DataObject != null && this.DataObject.Id != null && !flag) { try { base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.DataObject.Id, base.DataSession, typeof(ADUser))); base.DataSession.Delete(this.DataObject); } catch (DataSourceTransientException innerException) { base.WriteError(new RecipientTaskException(Strings.ErrorRemoveUserFailed(this.DataObject.Id.ToString()), innerException), ExchangeErrorCategory.ServerTransient, null); } finally { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } } TaskLogger.LogExit(); }
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(); }
internal static void DoubleWrite <TDataObject>(ObjectId objectId, TDataObject scratchPad, string ownerServerName, Fqdn domainController, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning) where TDataObject : ADConfigurationObject, new() { string configDC; try { writeVerbose(Strings.VerboseGetStoreConfigDCName(ownerServerName)); configDC = ADSession.GetConfigDC(TopologyProvider.LocalForestFqdn, ownerServerName); } catch (ADTransientException ex) { writeWarning(Strings.VerboseFailedDoubleWriteOperation(ex.Message)); TaskLogger.Trace("Failed to get the domain controller which store is using: {0}.", new object[] { ex.Message }); return; } if (domainController == null || !domainController.ToString().Equals(configDC, StringComparison.InvariantCultureIgnoreCase)) { IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(configDC, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 416, "DoubleWrite", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\common\\SystemConfigurationCommon.cs"); writeVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(objectId, configurationSession, typeof(TDataObject))); try { TDataObject tdataObject = configurationSession.Read <TDataObject>((ADObjectId)objectId); writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); if (tdataObject == null) { writeVerbose(Strings.VerboseFailedReadObjectFromDC(objectId.ToString(), typeof(TDataObject).Name, configDC)); TaskLogger.Trace("Failed to read the data object from config DC: \"{0}\"", new object[] { configDC }); TaskLogger.LogExit(); return; } tdataObject.CopyChangesFrom(scratchPad); writeVerbose(Strings.VerboseDoubleWriteADChangeOnDC(objectId.ToString(), configDC)); configurationSession.Save(tdataObject); } catch (DataValidationException ex2) { writeWarning(Strings.VerboseFailedDoubleWriteOperation(ex2.Message)); TaskLogger.Trace("Double write failed on DC '{0}': {1}", new object[] { configDC, ex2.ToString() }); } catch (ADOperationException ex3) { writeWarning(Strings.VerboseFailedDoubleWriteOperation(ex3.Message)); TaskLogger.Trace("Double write failed on DC '{0}': {1}", new object[] { configDC, ex3.ToString() }); } catch (DataSourceTransientException ex4) { writeWarning(Strings.VerboseFailedDoubleWriteOperation(ex4.Message)); TaskLogger.Trace("Double write failed on DC '{0}': {1}", new object[] { configDC, ex4.ToString() }); } finally { writeVerbose(TaskVerboseStringHelper.GetSourceVerboseString(configurationSession)); } } TaskLogger.LogExit(); }
protected override void InternalEndProcessing() { TaskLogger.LogEnter(); this.PrepareDataObjectToSave(); if (this.objectToSave != null) { try { this.PreSaveValidate(this.objectToSave); if (base.HasErrors) { return; } if (this.objectToSave.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(this.objectToSave, base.DataSession, typeof(MailboxDiscoverySearch))); } ((DiscoverySearchDataProvider)base.DataSession).CreateOrUpdate <MailboxDiscoverySearch>(this.objectToSave); SearchEventLogger.Instance.LogDiscoveryAndHoldSavedEvent(this.objectToSave); this.DataObject = this.objectToSave; if (this.InPlaceHoldEnabled && this.sourceMailboxIdParameters != null && this.sourceMailboxIdParameters.Count > 0) { LocalizedString localizedString = this.objectToSave.SynchronizeHoldSettings((DiscoverySearchDataProvider)base.DataSession, this.recipientSession, true, delegate(int percentage) { base.WriteProgress(Strings.NewMailboxSearchActivity, Strings.ApplyingHoldSettings(this.objectToSave.Name), percentage); }); if (localizedString != LocalizedString.Empty) { base.WriteError(new MailboxSearchTaskException(localizedString), ErrorCategory.InvalidOperation, this); } this.WriteWarning(Strings.WarningDiscoveryHoldDelay(COWSettings.COWCacheLifeTime.TotalMinutes)); } if (!base.HasErrors) { this.WriteResult(); } } catch (ObjectNotFoundException exception) { base.WriteError(exception, ErrorCategory.ObjectNotFound, null); } catch (DataSourceTransientException exception2) { base.WriteError(exception2, ErrorCategory.WriteError, null); } catch (ArgumentException exception3) { base.WriteError(exception3, ErrorCategory.WriteError, null); } catch (StorageTransientException innerException) { base.WriteError(new TaskException(Strings.ErrorMailboxSearchStorageTransient, innerException), ErrorCategory.WriteError, null); } catch (StoragePermanentException innerException2) { base.WriteError(new TaskException(Strings.ErrorMailboxSearchStoragePermanent, innerException2), ErrorCategory.WriteError, null); } finally { if (this.objectToSave.Identity != null) { base.WriteVerbose(TaskVerboseStringHelper.GetSourceVerboseString(base.DataSession)); } } } base.InternalEndProcessing(); TaskLogger.LogExit(); }
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); }