protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); TDataObject scratchPad = Activator.CreateInstance <TDataObject>(); scratchPad.CopyChangesFrom(this.DataObject); base.InternalProcessRecord(); TDataObject dataObject = this.DataObject; AmServerName amServerName = new AmServerName(dataObject.ServerName); TDataObject dataObject2 = this.DataObject; SystemConfigurationTasksHelper.DoubleWrite <TDataObject>(dataObject2.Identity, scratchPad, amServerName.Fqdn, base.DomainController, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); Database database = this.DataObject; if (database.Servers != null && database.Servers.Length > 0) { foreach (ADObjectId adobjectId in database.Servers) { DatabaseTasksHelper.RunConfigurationUpdaterRpcAsync(amServerName.Fqdn, database, ReplayConfigChangeHints.DbCopyAdded, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } } TaskLogger.LogExit(); }
protected void CreateTargetEdbDirectory() { TDataObject dataObject = this.DataObject; string pathName = dataObject.EdbFilePath.PathName; try { base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(this.m_server.Fqdn, pathName)); bool flag = false; string directoryName = Path.GetDirectoryName(pathName); TDataObject dataObject2 = this.DataObject; if (string.Compare(dataObject2.LogFolderPath.PathName, directoryName, StringComparison.InvariantCultureIgnoreCase) != 0) { TDataObject dataObject3 = this.DataObject; if (string.Compare(dataObject3.SystemFolderPath.PathName, directoryName, StringComparison.InvariantCultureIgnoreCase) != 0) { goto IL_82; } } flag = true; IL_82: if (!flag) { SystemConfigurationTasksHelper.TryCreateDirectory(this.m_server.Fqdn, directoryName, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } } catch (WmiException) { this.WriteWarning(Strings.FailedToGetCopyEdbFileStatus(this.m_server.Fqdn, pathName)); } }
private void ProcessMailboxTransportServerRole(bool isMailboxTransportServer, ITopologyConfigurationSession scSession, ADObjectId configContainerId) { ADObjectId childId = configContainerId.GetChildId("Mailbox"); IConfigurable[] array = base.DataSession.Find <MailboxTransportServer>(null, childId, true, null); if (isMailboxTransportServer) { if (array.Length == 0) { MailboxTransportServer mailboxTransportServer = new MailboxTransportServer(); mailboxTransportServer.NetworkAddress = this.DataObject.NetworkAddress; mailboxTransportServer.Name = "Mailbox"; mailboxTransportServer.Edition = ServerEditionType.StandardEvaluation; mailboxTransportServer.AdminDisplayVersion = ConfigurationContext.Setup.InstalledVersion; mailboxTransportServer.VersionNumber = SystemConfigurationTasksHelper.GenerateVersionNumber(ConfigurationContext.Setup.InstalledVersion); mailboxTransportServer.ExchangeLegacyDN = LegacyDN.GenerateLegacyDN(Server.GetParentLegacyDN(scSession), mailboxTransportServer); mailboxTransportServer.CurrentServerRole = ServerRole.Mailbox; mailboxTransportServer.SetId(childId); base.DataSession.Save(mailboxTransportServer); return; } } else if (array.Length > 0) { base.DataSession.Delete(array[0]); } }
protected override IConfigurable PrepareDataObject() { base.PrepareDataObject(); ITopologyConfigurationSession topologyConfigurationSession = (ITopologyConfigurationSession)base.DataSession; this.DataObject.Edition = ServerEditionType.StandardEvaluation; this.DataObject.AdminDisplayVersion = ConfigurationContext.Setup.InstalledVersion; this.DataObject.VersionNumber = SystemConfigurationTasksHelper.GenerateVersionNumber(ConfigurationContext.Setup.InstalledVersion); this.DataObject.MailboxRelease = MailboxRelease.E15; if (string.IsNullOrEmpty(this.Name)) { string localComputerFqdn = NativeHelpers.GetLocalComputerFqdn(true); int num = localComputerFqdn.IndexOf('.'); this.DataObject.Name = ((num == -1) ? localComputerFqdn : localComputerFqdn.Substring(0, num)); NewExchangeServer.TcpNetworkAddress value = new NewExchangeServer.TcpNetworkAddress(NetworkProtocol.TcpIP, localComputerFqdn); this.DataObject.NetworkAddress = new NetworkAddressCollection(value); } this.DataObject.FaultZone = "FaultZone1"; ADObjectId childId = topologyConfigurationSession.GetAdministrativeGroupId().GetChildId("Servers"); ADObjectId childId2 = childId.GetChildId(this.DataObject.Name); this.DataObject.SetId(childId2); this.DataObject.ExchangeLegacyDN = LegacyDN.GenerateLegacyDN(Server.GetParentLegacyDN(topologyConfigurationSession), this.DataObject); using (RegistryKey registryKey = RegistryUtil.OpenRemoteBaseKey(RegistryHive.LocalMachine, NativeHelpers.GetLocalComputerFqdn(true))) { using (RegistryKey registryKey2 = registryKey.OpenSubKey(NewExchangeServer.EdgeKeyName)) { if (registryKey2 == null && this.IsDomainJoined()) { this.SetServerSiteInformation(topologyConfigurationSession); } } } return(this.DataObject); }
protected override IConfigurable PrepareDataObject() { Server server = (Server)base.PrepareDataObject(); server.AdminDisplayVersion = ConfigurationContext.Setup.InstalledVersion; server.VersionNumber = SystemConfigurationTasksHelper.GenerateVersionNumber(ConfigurationContext.Setup.InstalledVersion); return(server); }
protected override void TranslateException(ref Exception e, out ErrorCategory category) { base.TranslateException(ref e, out category); category = (ErrorCategory)1001; if (SystemConfigurationTasksHelper.IsKnownMapiDotNETException(e)) { e = new InvalidOperationException(Strings.ErrorFailedToGetDatabaseStatus(this.Identity.ToString()), e); } }
protected override void TranslateException(ref Exception e, out ErrorCategory category) { base.TranslateException(ref e, out category); category = (ErrorCategory)1001; if (SystemConfigurationTasksHelper.IsKnownMapiDotNETException(e)) { TDataObject dataObject = this.DataObject; e = new InvalidOperationException(Strings.ErrorFailedToConnectToStore(dataObject.ServerName), e); } }
private bool GetExternalDirectoryOrganizationIdToLog(ADObject instance, out Guid externalDirectoryOrganizationId) { externalDirectoryOrganizationId = Guid.Empty; if (instance != null && instance.OrganizationId != OrganizationId.ForestWideOrgId) { ADOperationResult externalDirectoryOrganizationId2 = SystemConfigurationTasksHelper.GetExternalDirectoryOrganizationId(this.dataSession, instance.OrganizationId, out externalDirectoryOrganizationId); TenantSettingSyncLogGenerator.Instance.AddEventLogOnADException(externalDirectoryOrganizationId2); return(externalDirectoryOrganizationId2.Succeeded && externalDirectoryOrganizationId != Guid.Empty); } return(false); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(); base.InternalProcessRecord(); if (!this.SkipDatabaseLogFolderCreation) { string directoryName = Path.GetDirectoryName(this.EdbFilePath.PathName); SystemConfigurationTasksHelper.TryCreateDirectory(this.ownerServer.Fqdn, directoryName, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); SystemConfigurationTasksHelper.TryCreateDirectory(this.ownerServer.Fqdn, this.LogFolderPath.PathName, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); } TaskLogger.LogExit(); }
internal static void DoMaintenanceTask(PublicFolderDatabase publicStore, string domainController, Task.TaskWarningLoggingDelegate warningHandler) { Server server = publicStore.GetServer(); if (!server.IsExchange2007OrLater) { warningHandler(Strings.WarningSiteFolderCheckTaskNotAvailableOnTiServer(server.Name)); return; } string a = domainController; try { a = SystemConfigurationTasksHelper.GetConfigurationDomainControllerFqdn(domainController); } catch (SocketException ex) { warningHandler(Strings.ErrorResolveFqdnForDomainController(domainController, ex.Message)); } string configDC = ADSession.GetConfigDC(TopologyProvider.LocalForestFqdn, server.Name); if (string.Equals(a, configDC, StringComparison.InvariantCultureIgnoreCase)) { try { using (ExRpcAdmin exRpcAdmin = ExRpcAdmin.Create("Client=Management", server.Fqdn, null, null, null)) { exRpcAdmin.DoMaintenanceTask(publicStore.Guid, MaintenanceTask.SiteFolderCheck); } return; } catch (MapiPermanentException ex2) { TaskLogger.Trace("Set/New-OfflineAddressBook.InternalProcessRecord raises exception while running site folder check task: {0}", new object[] { ex2.Message }); warningHandler(Strings.ErrorFailedToRunSiteFolderCheckTask(server.Name, ex2.Message)); return; } catch (MapiRetryableException ex3) { TaskLogger.Trace("Set/New-OfflineAddressBook.InternalProcessRecord raises exception while running site folder check task: {0}", new object[] { ex3.Message }); warningHandler(Strings.ErrorFailedToRunSiteFolderCheckTask(server.Name, ex3.Message)); return; } } warningHandler(Strings.WarningOabSiteFolderCheckNotRun(server.Name)); }
protected override void InternalValidate() { string cmdletName = SystemConfigurationTasksHelper.GetCmdletName(typeof(GetTransportServer)); string cmdletName2 = SystemConfigurationTasksHelper.GetCmdletName(typeof(GetTransportService)); this.WriteWarning(Strings.TransportServerCmdletDeprecated(cmdletName, cmdletName2)); ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_TransportServerCmdletsDeprecated, new string[] { cmdletName, cmdletName2 }); base.InternalValidate(); }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); TDataObject scratchPad = Activator.CreateInstance <TDataObject>(); scratchPad.CopyChangesFrom(this.DataObject); base.InternalProcessRecord(); AmServerName amServerName = new AmServerName(this.OwnerServerName); TDataObject dataObject = this.DataObject; SystemConfigurationTasksHelper.DoubleWrite <TDataObject>(dataObject.Identity, scratchPad, amServerName.Fqdn, base.DomainController, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); TaskLogger.LogExit(); }
private static void FixTenantId(IConfigurable instance) { IPropertyBag propertyBag = instance as IPropertyBag; OrganizationId organizationId = (OrganizationId)propertyBag[ADObjectSchema.OrganizationId]; if (organizationId == null) { return; } IConfigDataProvider tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(null, true, ConsistencyMode.IgnoreInvalid, null, ADSessionSettings.FromAllTenantsOrRootOrgAutoDetect(organizationId), 192, "FixTenantId", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\MessageHygiene\\HygieneConfiguration\\FfoDualWriter.cs"); Guid objectGuid; ADOperationResult externalDirectoryOrganizationId = SystemConfigurationTasksHelper.GetExternalDirectoryOrganizationId(tenantOrTopologyConfigurationSession, organizationId, out objectGuid); if (!externalDirectoryOrganizationId.Succeeded) { throw new InvalidOperationException("Error resolving orgId to external org id", externalDirectoryOrganizationId.Exception); } string distinguishedName = FfoDualWriter.FfoRootDN.GetChildId(organizationId.OrganizationalUnit.Name).GetChildId(objectGuid.ToString()).DistinguishedName; propertyBag[ADObjectSchema.OrganizationalUnitRoot] = new ADObjectId(distinguishedName, objectGuid); }
private bool TryCopyPath(string originalPath, string newPath, WmiWrapper.FileFilter filter) { bool result = true; try { if (SystemConfigurationTasksHelper.TryCreateDirectory(this.ownerServer.Fqdn, newPath, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning))) { base.WriteVerbose(Strings.VerboseCheckDirectoryExistenceCondition(this.OwnerServer.Fqdn, originalPath)); if (WmiWrapper.IsDirectoryExisting(this.OwnerServer.Fqdn, originalPath)) { base.WriteVerbose(Strings.VerboseCopyDirectory(this.OwnerServer.Fqdn, originalPath, newPath)); if (!WmiWrapper.CopyFilesInDirectory(this.OwnerServer.Fqdn, originalPath, newPath, filter)) { result = false; } } else { TaskLogger.Trace("Original directory does not exist, nothing to copy.", new object[0]); } } else { result = false; } } catch (ManagementException ex) { base.WriteVerbose(Strings.VerboseEatUpException(ex.Message)); TaskLogger.Trace("Error occurs when copying path: {0}", new object[] { ex.Message }); result = false; } return(result); }
internal void SeedDatabase(ReplayConfiguration config) { ReplayState replayState = config.ReplayState; if (config is RemoteReplayConfiguration) { string targetMachine = config.TargetMachine; try { string machineFqdn = targetMachine; string destinationLogPath = config.DestinationLogPath; string destinationEdbPath = config.DestinationEdbPath; TDataObject dataObject = this.DataObject; AddDatabaseCopyTaskBase <TDataObject> .CheckSeedingPath(machineFqdn, destinationLogPath, destinationEdbPath, dataObject.LogFilePrefix); } catch (SeedingPathWarningException ex) { if (this.m_SeedingPostponedSpecified) { base.WriteWarning(ex.Message); } return; } catch (SeedingPathErrorException exception) { base.WriteError(exception, ErrorCategory.InvalidOperation, this.Identity); } SystemConfigurationTasksHelper.TryCreateDirectory(this.m_server.Fqdn, config.DestinationLogPath, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning)); using (TaskSeeder taskSeeder = this.ConstructSeeder()) { taskSeeder.SeedDatabase(); } return; } throw new NotSupportedException(config.GetType() + " is not supported"); }
private static void UpdateRecipients(EmailAddressPolicy eap, OrganizationId organizationId, string domainController, IRecipientSession globalCatalogSession, Task.TaskVerboseLoggingDelegate writeVerbose, Task.TaskWarningLoggingDelegate writeWarning, WriteProgress writeProgress, Task cmdlet, bool fixMissingAlias) { UpdateEmailAddressPolicy.AssertArgumentNotNull(eap, "eap"); UpdateEmailAddressPolicy.AssertArgumentNotNull(writeVerbose, "writeVerbose"); UpdateEmailAddressPolicy.AssertArgumentNotNull(writeWarning, "writeWarning"); UpdateEmailAddressPolicy.AssertArgumentNotNull(writeProgress, "writeProgress"); if (string.IsNullOrEmpty(eap.LdapRecipientFilter) && !fixMissingAlias) { return; } int num = 0; try { if (cmdlet != null && cmdlet.Stopping) { return; } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, globalCatalogSession.SessionSettings, 409, "UpdateRecipients", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\RecipientPolicy\\UpdateEmailAddressPolicy.cs"); tenantOrRootOrgRecipientSession.EnforceDefaultScope = false; IEnumerable <ADRecipient> enumerable = eap.FindMatchingRecipientsPaged(globalCatalogSession, organizationId, null, fixMissingAlias); string text = null; Hashtable hashtable = new Hashtable(); foreach (ADRecipient adrecipient in enumerable) { if (cmdlet != null && cmdlet.Stopping) { return; } if (!string.IsNullOrEmpty(domainController) && string.IsNullOrEmpty(text)) { try { string configurationDomainControllerFqdn = SystemConfigurationTasksHelper.GetConfigurationDomainControllerFqdn(domainController); int num2 = configurationDomainControllerFqdn.IndexOf("."); if (0 <= num2) { text = configurationDomainControllerFqdn.Substring(num2); } } catch (SocketException ex) { writeWarning(Strings.ErrorResolveFqdnForDomainController(domainController, ex.Message)); return; } } string text2 = adrecipient.Id.DomainId.DistinguishedName.ToLowerInvariant(); if (!hashtable.ContainsKey(text2)) { SystemConfigurationTasksHelper.PrepareDomainControllerRecipientSessionForUpdate(tenantOrRootOrgRecipientSession, adrecipient.Id, domainController, text); IEnumerable <ADRecipient> collection = eap.FindMatchingRecipientsPaged(tenantOrRootOrgRecipientSession, organizationId, adrecipient.Id, fixMissingAlias); List <ADRecipient> list = new List <ADRecipient>(); Exception ex2 = null; Exception ex3 = null; try { list.AddRange(collection); } catch (DataSourceOperationException ex4) { TaskLogger.Trace("Exception caught when re-read recipient from DC : {0}", new object[] { ex4.ToString() }); if (ex4.InnerException is ActiveDirectoryObjectNotFoundException || ex4.InnerException is AuthenticationException) { ex3 = ex4; } else { ex2 = ex4; } } catch (DataSourceTransientException ex5) { TaskLogger.Trace("Exception caught when re-read recipient from DC : {0}", new object[] { ex5.ToString() }); if (ex5.InnerException is ActiveDirectoryOperationException || ex5.InnerException is ActiveDirectoryServerDownException) { ex3 = ex5; } else { ex2 = ex5; } } if (ex3 != null) { hashtable.Add(text2, null); writeWarning(Strings.ErrorCannotUpdateRecipientOfDomain(DNConvertor.FqdnFromDomainDistinguishedName(text2), ex3.Message)); } else if (ex2 != null) { writeWarning(Strings.ErrorFailedToReadRecipientForUpdate(adrecipient.Id.ToString(), ex2.Message)); } else if (1 == list.Count) { ADRecipient adrecipient2 = list[0]; if (cmdlet != null && cmdlet.Stopping) { return; } num = num++ % 99 + 1; writeProgress(Strings.ProgressActivityUpdateRecipient, Strings.ProgressStatusUpdateRecipient(adrecipient2.Id.ToString()), num); writeVerbose(Strings.ProgressStatusUpdateRecipient(adrecipient2.Id.ToString())); try { if (fixMissingAlias && string.IsNullOrEmpty(adrecipient2.Alias)) { if (adrecipient2 is ADMicrosoftExchangeRecipient) { adrecipient2.Alias = RecipientTaskHelper.GenerateUniqueAlias(globalCatalogSession, adrecipient2.OrganizationId, ADMicrosoftExchangeRecipient.DefaultName, writeVerbose); } else if (adrecipient2 is ADSystemAttendantMailbox) { adrecipient2.Alias = RecipientTaskHelper.GenerateUniqueAlias(globalCatalogSession, adrecipient2.OrganizationId, (adrecipient2 as ADSystemAttendantMailbox).ServerName + "-SA", writeVerbose); } else { adrecipient2.Alias = RecipientTaskHelper.GenerateUniqueAlias(globalCatalogSession, adrecipient2.OrganizationId, adrecipient2.Name, writeVerbose); } writeWarning(Strings.WarningGeneratingMissingAlias(adrecipient2.Identity.ToString(), adrecipient2.Alias)); } if (!adrecipient2.IsReadOnly) { ProvisioningLayer.UpdateAffectedIConfigurable(cmdlet, RecipientTaskHelper.ConvertRecipientToPresentationObject(adrecipient2), true); } if (!adrecipient2.IsValid || adrecipient2.IsReadOnly) { writeWarning(Strings.ErrorCannotUpdateInvalidRecipient(adrecipient2.Id.ToString())); } else { if (cmdlet.IsVerboseOn && adrecipient2.ObjectState != ObjectState.Unchanged) { writeVerbose(TaskVerboseStringHelper.GetConfigurableObjectChangedProperties(adrecipient2)); } tenantOrRootOrgRecipientSession.Save(adrecipient2); } } catch (DataSourceTransientException ex6) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex6.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex6.Message }); } catch (DataSourceOperationException ex7) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex7.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex7.Message }); } catch (DataValidationException ex8) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex8.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex8.Message }); } } } } } finally { if (cmdlet != null && cmdlet.Stopping) { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_RecipientsUpdateForEmailAddressPolicyCancelled, new string[] { eap.Identity.ToString(), eap.LdapRecipientFilter, ADRecipientSchema.EmailAddresses.Name }); } } if (num != 0) { writeVerbose(Strings.ProgressStatusFinished); writeProgress(Strings.ProgressActivityUpdateRecipient, Strings.ProgressStatusFinished, 100); } }
public static bool TryCreateDirectory(string serverFQDN, string directoryPath, FileSystemAccessRule[] directoryPermissions, Task.TaskVerboseLoggingDelegate verboseDelegate, Task.TaskWarningLoggingDelegate warningDelegate) { bool flag = false; if (string.Compare(serverFQDN, NativeHelpers.GetLocalComputerFqdn(false), StringComparison.InvariantCultureIgnoreCase) == 0) { try { verboseDelegate(Strings.VerboseCheckDirectoryExistenceCondition(serverFQDN, directoryPath)); if (Directory.Exists(directoryPath)) { if (directoryPermissions != null) { DirectorySecurity directorySecurity = SystemConfigurationTasksHelper.CreateDirectorySecurityHelper(directoryPermissions); directorySecurity.SetAccessRuleProtection(true, false); verboseDelegate(Strings.VerboseSetAccessControl(serverFQDN, directoryPath)); TaskLogger.Trace("Directory \"" + directoryPath + "\" already exists on the local machine, just set the access control.", new object[0]); Directory.SetAccessControl(directoryPath, directorySecurity); flag = true; } else { verboseDelegate(Strings.VerboseNoAccessControlSpecified(serverFQDN, directoryPath)); TaskLogger.Trace("No access control specified to be set on directory \"" + directoryPath + "\".", new object[0]); flag = true; } } else if (directoryPermissions != null) { DirectorySecurity directorySecurity = SystemConfigurationTasksHelper.CreateDirectorySecurityHelper(directoryPermissions); directorySecurity.SetAccessRuleProtection(true, false); verboseDelegate(Strings.VerboseCreateDirectory(serverFQDN, directoryPath)); TaskLogger.Trace("Directory \"" + directoryPath + "\" does not exist. Create the directory on the local machine and set the access control.", new object[0]); Directory.CreateDirectory(directoryPath, directorySecurity); flag = true; } else { verboseDelegate(Strings.VerboseCreateDirectory(serverFQDN, directoryPath)); verboseDelegate(Strings.VerboseNoAccessControlSpecified(serverFQDN, directoryPath)); TaskLogger.Trace("Directory \"" + directoryPath + "\" does not exist. Create the directory on the local machine. No access controls specified to set on the directory.", new object[0]); Directory.CreateDirectory(directoryPath); flag = true; } goto IL_43C; } catch (NotSupportedException ex) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex.ToString() }); goto IL_43C; } catch (ArgumentNullException ex2) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex2.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex2.ToString() }); goto IL_43C; } catch (UnauthorizedAccessException ex3) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex3.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex3.ToString() }); goto IL_43C; } catch (ArgumentException ex4) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex4.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex4.ToString() }); goto IL_43C; } catch (IOException ex5) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex5.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex5.ToString() }); goto IL_43C; } } try { verboseDelegate(Strings.VerboseCheckDirectoryExistenceCondition(serverFQDN, directoryPath)); uint num; if (!WmiWrapper.IsDirectoryExisting(serverFQDN, directoryPath)) { verboseDelegate(Strings.VerboseCreateDirectory(serverFQDN, directoryPath)); TaskLogger.Trace(string.Concat(new string[] { "Create the directory \"", directoryPath, "\" on the remote machine \"", serverFQDN, "\"." }), new object[0]); num = WmiWrapper.CreateDirectory(serverFQDN, directoryPath); } else { num = 0U; } if (num == 0U) { if (directoryPermissions != null) { verboseDelegate(Strings.VerboseSetAccessControl(serverFQDN, directoryPath)); TaskLogger.Trace(string.Concat(new string[] { "Set the access control for directory \"", directoryPath, "\" on the remote machine \"", serverFQDN, "\"." }), new object[0]); num = WmiWrapper.ChangeSecurityPermissions(serverFQDN, directoryPath, directoryPermissions); if (num == 0U) { flag = true; } else { verboseDelegate(Strings.VerboseFailedSetAccessControl(serverFQDN, directoryPath, "WMI Status: " + num.ToString())); TaskLogger.Trace("this.TryCreateDirectory() failed to set the access control on the directory - WMI Status: {0}", new object[] { num.ToString() }); } } else { verboseDelegate(Strings.VerboseNoAccessControlSpecified(serverFQDN, directoryPath)); TaskLogger.Trace("No access control specified to be set on directory \"" + directoryPath + "\".", new object[0]); flag = true; } } else { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, "WMI Status: " + num.ToString())); TaskLogger.Trace("this.TryCreateDirectory() failed to create the directory - WMI Status: {0}", new object[] { num.ToString() }); } } catch (WmiException ex6) { verboseDelegate(Strings.VerboseFailedCreateDirectory(serverFQDN, directoryPath, ex6.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex6.ToString() }); } catch (UnauthorizedAccessException ex7) { verboseDelegate(Strings.ErrorFailedToConnectToServer(serverFQDN, ex7.Message)); TaskLogger.Trace("this.TryCreateDirectory() raised exception: {0}", new object[] { ex7.ToString() }); } IL_43C: if (!flag) { warningDelegate(Strings.WarningFailedCreateDirectory(serverFQDN, directoryPath)); } return(flag); }
protected override void InternalValidate() { TaskLogger.LogEnter(); base.InternalValidate(); if (this.OwnerServer == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } base.VerifyIsWithinScopes((IConfigurationSession)base.DataSession, this.OwnerServer, true, new DataAccessTask <Database> .ADObjectOutOfScopeString(Strings.ErrorServerOutOfScope)); if (this.DataObject != null) { MapiTaskHelper.VerifyDatabaseAndItsOwningServerInScope(base.SessionSettings, this.DataObject, new Task.ErrorLoggerDelegate(base.WriteError)); } ADObjectId adobjectId = new ADObjectId(this.OwnerServer.Guid); if (null == this.EdbFilePath && (base.Fields.IsModified("EdbFilePath") || base.Fields.IsChanged("EdbFilePath"))) { base.WriteError(new ArgumentException(Strings.ErrorInvalidParameterValue("EdbFilePath", "null"), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } if (!this.IsEdbFilePathChanged && !this.isLogFolderPathChanged) { this.WriteWarning(Strings.FileLocationNotChanged); TaskLogger.LogExit(); return; } this.needReportProgress = !base.ConfigurationOnly; this.shouldContinueToDoConfigurationOnly = true; try { QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Guid, this.DataObject.Guid); ADObjectId rootId = this.DataObject.IsExchange2009OrLater ? this.DataObject.AdministrativeGroup.GetChildId("Databases") : this.DataObject.Server; IEnumerable <Database> collection = base.DataSession.FindPaged <Database>(filter, rootId, true, null, 0); List <Database> databases = new List <Database>(collection); if (this.IsEdbFilePathChanged) { if (this.DataObject.IsExchange2009OrLater) { base.WriteVerbose(Strings.VerboseEdbFileLocationUniqueUnderDAGCondition(this.EdbFilePath.PathName)); ADObjectId[] serversId; if (this.DataObject.Servers != null && this.DataObject.Servers.Length != 0) { serversId = this.DataObject.Servers; } else { serversId = new ADObjectId[] { this.DataObject.Server }; } if (!new EdbFileLocationUniqueUnderDAGCondition(this.EdbFilePath.PathName, adobjectId, serversId, databases).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotUniqueUnderSameDAG(this.EdbFilePath.PathName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } } else { base.WriteVerbose(Strings.VerboseEdbFileLocationUniqueUnderServerCondition(base.OwnerServerName, this.EdbFilePath.PathName)); if (!new EdbFileLocationUniqueUnderServerCondition(this.EdbFilePath.PathName, adobjectId, databases).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotUniqueUnderSameNode(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } } } if (this.isLogFolderPathChanged) { if (this.DataObject.IsExchange2009OrLater) { ADObjectId[] serversId2; if (this.DataObject.Servers != null && this.DataObject.Servers.Length != 0) { serversId2 = this.DataObject.Servers; } else { serversId2 = new ADObjectId[] { this.DataObject.Server }; } if (!new DbLogLocationUniqueUnderDAGCondition(this.LogFolderPath.PathName, adobjectId, serversId2, databases).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotUniqueUnderSameDAG(this.LogFolderPath.PathName), "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity); } } else if (!new DbLogLocationUniqueUnderServerCondition(this.LogFolderPath.PathName, adobjectId, databases).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotUniqueUnderTheSameNode(this.LogFolderPath.PathName, base.OwnerServerName), "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity); } } if (base.ConfigurationOnly) { this.moveCatalogs = false; if (!this.Force && !(this.shouldContinueToDoConfigurationOnly = base.ShouldContinue(Strings.WarningUseConfigurationOnly))) { TaskLogger.LogExit(); return; } if (this.IsEdbFilePathChanged) { base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.TargetEdbFilePath.PathName)); if (new FileNotExistCondition(this.OwnerServer.Fqdn, this.TargetEdbFilePath.PathName).Verify()) { this.WriteWarning(Strings.WarningEdbFileLocationNotExists(this.EdbFilePath.PathName)); } } TaskLogger.LogExit(); return; } else { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressValidatingFileLocations, Strings.ProgressMoveDatabasePath(this.Identity.ToString()), 5); } if (this.IsEdbFilePathChanged) { if (this.OriginalEdbFilePath == null) { base.WriteError(new InvalidOperationException(Strings.ErrorOriginalEdbFilePathMissed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity); } if (this.IsDatabaseFilesCreated) { base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.OriginalEdbFilePath.PathName)); if (new FileNotExistCondition(this.OwnerServer.Fqdn, this.OriginalEdbFilePath.PathName).Verify()) { base.WriteError(new InvalidOperationException(Strings.ErrorSourceFileNotFound(base.OwnerServerName, this.OriginalEdbFilePath.PathName)), ErrorCategory.InvalidOperation, this.Identity); } } base.WriteVerbose(Strings.VerbosePathOnFixedOrNetworkDriveCondition(base.OwnerServerName, this.EdbFilePath.PathName)); if (!new PathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorEdbFileLocationNotOnFixedDrive(this.EdbFilePath.PathName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } base.WriteVerbose(Strings.VerboseCheckFileExistenceCondition(base.OwnerServerName, this.EdbFilePath.PathName)); if (!new FileNotExistCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorEdbFilePathOccupiedByFile(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } base.WriteVerbose(Strings.VerboseCheckDirectoryExistenceCondition(base.OwnerServerName, this.EdbFilePath.PathName)); if (!new DirectoryNotExistCondition(this.OwnerServer.Fqdn, this.EdbFilePath.PathName).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorEdbFilePathOccupiedByDirectory(this.EdbFilePath.PathName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidArgument, this.Identity); } string directoryName = Path.GetDirectoryName(this.EdbFilePath.PathName); if (this.IsDatabaseFilesCreated && !SystemConfigurationTasksHelper.TryCreateDirectory(this.OwnerServer.Fqdn, directoryName, Database_Directory.GetDomainWidePermissions(), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning))) { base.WriteError(new ArgumentException(Strings.ErrorEdbFileDirectoryNotExist(directoryName, base.OwnerServerName), "EdbFilePath"), ErrorCategory.InvalidOperation, this.Identity); } if (this.moveCatalogs) { this.moveCatalogs = this.DataObject.ObjectClass.Contains("msExchPrivateMDB"); if (this.moveCatalogs) { string directoryName2 = Path.GetDirectoryName(this.OriginalEdbFilePath.PathName); this.originalCatalogsPath = this.GenerateCatalogPath(directoryName2, this.DataObject.Guid); base.WriteVerbose(Strings.VerboseCheckDirectoryExistenceCondition(base.OwnerServerName, this.originalCatalogsPath)); this.moveCatalogs = WmiWrapper.IsDirectoryExisting(this.OwnerServer.Fqdn, this.originalCatalogsPath); if (this.moveCatalogs) { string directoryName3 = Path.GetDirectoryName(this.EdbFilePath.PathName); this.targetCatalogsPath = this.GenerateCatalogPath(directoryName3, this.DataObject.Guid); this.moveCatalogs = (this.originalCatalogsPath != this.targetCatalogsPath); } } } } else { this.moveCatalogs = false; } if (base.ConfigurationOnly) { TaskLogger.LogExit(); return; } if (this.isLogFolderPathChanged) { if (this.OldLogFolderPath == null) { base.WriteError(new InvalidOperationException(Strings.ErrorOriginalLogFolderPathIsMissed(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } base.WriteVerbose(Strings.VerbosePathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName)); if (!new PathOnFixedOrNetworkDriveCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorPathIsNotOnFixedDrive("LogFolderPath")), ErrorCategory.InvalidArgument, this.DataObject.Identity); } base.WriteVerbose(Strings.VerboseLogLocationAvailableCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName)); if (!new LogLocationAvailableCondition(this.OwnerServer.Fqdn, this.LogFolderPath.PathName, this.DataObject.LogFilePrefix).Verify()) { base.WriteError(new ArgumentException(Strings.ErrorLogFolderPathNotAvailable, "LogFolderPath"), ErrorCategory.InvalidArgument, this.DataObject.Identity); } base.WriteVerbose(Strings.VerboseCheckLogFileExistingInPath(this.OwnerServer.Fqdn, this.oldLogFolderPath.PathName)); if (!WmiWrapper.IsFileExistingInPath(this.OwnerServer.Fqdn, this.oldLogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter))) { base.WriteError(new InvalidOperationException(Strings.ErrorMoveDatabasePathAsSourceFileNotExist(this.oldLogFolderPath.PathName)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } } } } catch (WmiException ex) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex.Message)), ErrorCategory.InvalidOperation, this.Identity); } catch (UnauthorizedAccessException ex2) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex2.Message)), ErrorCategory.InvalidOperation, this.Identity); } if (this.DataObject.ReplicationType == ReplicationType.Remote && !this.DataObject.Recovery) { base.WriteError(new InvalidOperationException(Strings.ErrorMoveDatabasePathInvalidOnReplicated), ErrorCategory.InvalidOperation, this.DataObject.Identity); } TaskLogger.LogExit(); }
internal static void UpdateRecipients(AddressBookBase abb, ADObjectId[] removedAbbTreeIds, string domainController, IRecipientSession globalCatalogSession, Task.TaskWarningLoggingDelegate writeWarning, WriteProgress writeProgress, Cmdlet cmdlet) { if (abb == null) { throw new ArgumentNullException("abb"); } if (Guid.Empty == abb.Guid) { throw new ArgumentNullException("abb.Guid"); } if (writeWarning == null) { throw new ArgumentNullException("writeWarning"); } if (writeProgress == null) { throw new ArgumentNullException("writeProgress"); } int num = 0; try { if (cmdlet != null && cmdlet.Stopping) { return; } string domainControllerFqdn = null; if (!string.IsNullOrEmpty(domainController)) { try { domainControllerFqdn = SystemConfigurationTasksHelper.GetConfigurationDomainControllerFqdn(domainController); } catch (SocketException ex) { writeWarning(Strings.ErrorResolveFqdnForDomainController(domainController, ex.Message)); return; } } if (string.IsNullOrEmpty(abb.LdapRecipientFilter) || removedAbbTreeIds != null) { List <Guid> list = new List <Guid>(); if (removedAbbTreeIds != null) { foreach (ADObjectId adobjectId in removedAbbTreeIds) { list.Add(adobjectId.ObjectGuid); } list.Sort(); } else { list.Add(abb.Guid); } QueryFilter[] array = null; int num2 = LdapFilterBuilder.MaxCustomFilterTreeSize - 1; for (int j = 0; j < list.Count; j += num2) { int num3 = Math.Min(num2, list.Count - j); if (array == null || array.Length != num3) { array = new QueryFilter[num3]; } for (int k = 0; k < num3; k++) { array[k] = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.AddressListMembership, new ADObjectId(list[k + j])); } QueryFilter queryFilter = new OrFilter(array); ADPagedReader <ADRecipient> adpagedReader = globalCatalogSession.FindPaged(null, QueryScope.SubTree, queryFilter, null, 0); using (IEnumerator <ADRecipient> enumerator = adpagedReader.GetEnumerator()) { UpdateAddressBookBase <TIdParameter> .InternalUpdateRecipients(enumerator, null, queryFilter, list, domainControllerFqdn, globalCatalogSession, writeWarning, writeProgress, cmdlet, ref num); } } } else { IEnumerator <ADRecipient> enumerator2 = abb.FindUpdatingRecipientsPaged(globalCatalogSession, null).GetEnumerator(); UpdateAddressBookBase <TIdParameter> .InternalUpdateRecipients(enumerator2, abb, null, null, domainControllerFqdn, globalCatalogSession, writeWarning, writeProgress, cmdlet, ref num); } } finally { if (cmdlet != null && cmdlet.Stopping) { ExManagementApplicationLogger.LogEvent(ManagementEventLogConstants.Tuple_RecipientsUpdateForAddressBookCancelled, new string[] { string.Format("{0} (objectGUID=<{1}>)", abb.DistinguishedName ?? string.Empty, abb.Guid.ToString()), abb.LdapRecipientFilter, ADRecipientSchema.AddressListMembership.Name }); } } if (num != 0) { writeProgress(Strings.ProgressActivityUpdateRecipient, Strings.ProgressStatusFinished, 100); } }
protected override void InternalProcessRecord() { TaskLogger.LogEnter(new object[] { this.DataObject }); bool flag = false; bool flag2 = false; bool flag3 = true; bool flag4 = false; bool flag5 = false; Server server = this.OwnerServer; ADObjectId id = new ADObjectId(this.OwnerServer.Guid); if (server == null) { base.WriteError(new InvalidOperationException(Strings.ErrorDBOwningServerNotFound(this.DataObject.Identity.ToString())), ErrorCategory.InvalidOperation, this.DataObject.Identity); } try { if ((!this.IsEdbFilePathChanged && !this.isLogFolderPathChanged) || (base.ConfigurationOnly && !this.shouldContinueToDoConfigurationOnly)) { TaskLogger.LogExit(); } else { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCheckingReplayState, 10); } base.WriteVerbose(Strings.VerboseConnectionAdminRpcInterface(this.OwnerServer.Fqdn)); MdbStatus mdbStatus = AmStoreHelper.GetMdbStatus(this.OwnerServer.Fqdn, this.DataObject.Guid); if (mdbStatus == null) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToGetDatabaseStatus(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity); } if ((mdbStatus.Status & MdbStatusFlags.Backup) != MdbStatusFlags.Offline) { base.WriteError(new InvalidOperationException(Strings.ErrorBackupInProgress(this.Identity.ToString())), ErrorCategory.InvalidOperation, this.Identity); } else if ((mdbStatus.Status & MdbStatusFlags.Online) != MdbStatusFlags.Offline) { if (!this.Force && !base.ShouldContinue(base.ConfigurationOnly ? Strings.WarningDismountDatabaseToDoConfigurationOnly(this.Identity.ToString()) : Strings.WarningDismountDatabaseToContinue(this.Identity.ToString()))) { TaskLogger.LogExit(); return; } if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDismountingDatabase(this.Identity.ToString()), 20); } base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(id, base.DataSession, typeof(Server))); try { base.WriteVerbose(Strings.VerboseUnmountDatabase(this.DataObject.Identity.ToString())); AmRpcClientHelper.DismountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), 0); } catch (AmServerException ex) { Exception ex2; if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex.TryGetInnerExceptionOfType(out ex2)) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex2.Message }); } else if (ex is AmDatabaseNeverMountedException) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex.Message }); } else { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while unmounting database: {0}", new object[] { ex.Message }); base.WriteError(ex, ErrorCategory.InvalidOperation, this.DataObject.Identity); } } catch (AmServerTransientException ex3) { TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while dismounting database: {0}", new object[] { ex3.Message }); base.WriteError(ex3, ErrorCategory.InvalidOperation, this.DataObject.Identity); } flag = true; } if (!base.ConfigurationOnly) { if (this.IsDatabaseFilesCreated && this.IsEdbFilePathChanged) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingEdbFile, 25); } if (!this.TryCopyFile(this.OriginalEdbFilePath.PathName, this.TargetEdbFilePath.PathName)) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMoveEdbFile(this.OriginalEdbFilePath.PathName, this.TargetEdbFilePath.PathName)), ErrorCategory.InvalidOperation, this.Identity); } flag2 = true; } if (this.isLogFolderPathChanged) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingLogFiles, 45); } base.WriteVerbose(Strings.VerboseCopyDatabaseLogFiles(base.OwnerServerName, this.OldLogFolderPath.PathName, this.LogFolderPath.PathName)); if (!this.TryCopyPath(this.OldLogFolderPath.PathName, this.LogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter))) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMoveDatabaseLogFiles(this.OldLogFolderPath.PathName, this.LogFolderPath.PathName)), ErrorCategory.InvalidOperation, this.DataObject.Identity); } flag4 = true; } } if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressSavingADObject, 69); } base.InternalProcessRecord(); flag3 = false; if (flag2) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingEdbFile, 72); } if (!this.TryDeleteFile(this.OriginalEdbFilePath.PathName)) { this.WriteWarning(Strings.FailedToDeleteOldEdbFile(this.OriginalEdbFilePath.PathName)); TaskLogger.Trace("MoveDatabasePath: delete edb \"{0}\" file failed", new object[] { this.OriginalEdbFilePath.PathName }); } } if (flag4) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingLogFiles, 81); } base.WriteVerbose(Strings.VerboseDeleteDatabaseLogFiles(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName)); if (!WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogPathFilter))) { this.WriteWarning(Strings.FailedDeleteOldDatabaseLogFiles(this.OwnerServer.Fqdn, this.OldLogFolderPath.PathName)); TaskLogger.Trace("Failed to delete some of the orignal log files.", new object[0]); } } if (this.moveCatalogs && SystemConfigurationTasksHelper.TryCreateDirectory(this.OwnerServer.Fqdn, this.targetCatalogsPath, null, new Task.TaskVerboseLoggingDelegate(base.WriteVerbose), new Task.TaskWarningLoggingDelegate(this.WriteWarning))) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressCopyingCatalog, 87); } try { base.WriteVerbose(Strings.VerboseCopyDatabaseCatalogFiles(this.OwnerServer.Fqdn, this.originalCatalogsPath, this.targetCatalogsPath)); if (WmiWrapper.CopyFilesInDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath, this.targetCatalogsPath, new WmiWrapper.FileFilter(MoveDatabasePath.ReturnAllFiles))) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressDeletingCatalog, 92); } base.WriteVerbose(Strings.VerboseDeleteDatabaseCatalogFiles(this.OwnerServer.Fqdn, this.originalCatalogsPath)); WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath, new WmiWrapper.FileFilter(MoveDatabasePath.ReturnAllFiles)); base.WriteVerbose(Strings.VerboseDeleteDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath)); WmiWrapper.RemoveDirectory(this.OwnerServer.Fqdn, this.originalCatalogsPath); } } catch (ManagementException ex4) { TaskLogger.Trace("MoveDatabasePath raised exception {0} while moving catalog files", new object[] { ex4.ToString() }); this.WriteWarning(Strings.ErrorMovingCatalogs(this.Identity.ToString(), ex4.Message)); } catch (ArgumentException ex5) { TaskLogger.Trace("MoveDatabasePath raised exception {0} while moving catalog files", new object[] { ex5.ToString() }); this.WriteWarning(Strings.ErrorMovingCatalogs(this.Identity.ToString(), ex5.Message)); } } this.SendNotificationRpcToReplayService(); flag5 = true; } } catch (WmiException ex6) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex6.Message)), ErrorCategory.InvalidOperation, this.Identity); } catch (UnauthorizedAccessException ex7) { base.WriteError(new InvalidOperationException(Strings.ErrorFailedToConnectToServer(base.OwnerServerName, ex7.Message)), ErrorCategory.InvalidOperation, this.Identity); } finally { if (flag3) { if (flag2 && !this.TryDeleteFile(this.TargetEdbFilePath.PathName)) { this.WriteWarning(Strings.FailedToDeleteTempEdbFile(this.TargetEdbFilePath.PathName)); TaskLogger.Trace("MoveDatabasePath: delete edb \"{0}\" file failed", new object[] { this.TargetEdbFilePath.PathName }); } if (flag4) { TaskLogger.Trace("Error occurs when Copying path. delete copied log files", new object[0]); base.WriteVerbose(Strings.VerboseDeleteDatabaseLogFiles(this.OwnerServer.Fqdn, this.LogFolderPath.PathName)); if (!WmiWrapper.DeleteFilesInDirectory(this.OwnerServer.Fqdn, this.LogFolderPath.PathName, new WmiWrapper.FileFilter(this.LogFileFilter))) { this.WriteWarning(Strings.FailedDeleteTempDatabaseLogFiles(base.OwnerServerName, this.LogFolderPath.PathName)); TaskLogger.Trace("Failed to delete some of the copied log files.", new object[0]); } } } if (!base.ConfigurationOnly && flag) { if (this.needReportProgress) { base.WriteProgress(Strings.ProgressMoveDatabasePath(this.Identity.ToString()), Strings.ProgressRestoringDatabaseStatus, 95); } base.WriteVerbose(TaskVerboseStringHelper.GetReadObjectVerboseString(id, base.DataSession, typeof(Server))); try { if (!flag5) { this.SendNotificationRpcToReplayService(); flag5 = true; } base.WriteVerbose(Strings.VerboseMountDatabase(this.Identity.ToString())); AmRpcClientHelper.MountDatabase(ADObjectWrapperFactory.CreateWrapper(this.DataObject), 0, 0, 0); } catch (AmServerException ex8) { string message = ex8.Message; TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while re-mounting Mdb status: {0}", new object[] { message }); this.WriteWarning(Strings.ErrorFailedToRestoreDatabaseStatus(this.Identity.ToString(), message)); } catch (AmServerTransientException ex9) { string message2 = ex9.Message; TaskLogger.Trace("MoveDatabasePath.InternalProcessRecord raises exception while re-mounting Mdb status: {0}", new object[] { message2 }); this.WriteWarning(Strings.ErrorFailedToRestoreDatabaseStatus(this.Identity.ToString(), message2)); } } TaskLogger.LogExit(); } }
protected override bool IsKnownException(Exception exception) { return(base.IsKnownException(exception) || SystemConfigurationTasksHelper.IsKnownWmiException(exception) || SystemConfigurationTasksHelper.IsKnownMapiDotNETException(exception) || SystemConfigurationTasksHelper.IsKnownClusterUpdateDatabaseResourceException(exception)); }
protected override bool IsKnownException(Exception e) { return(AmExceptionHelper.IsKnownClusterException(this, e) || SystemConfigurationTasksHelper.IsKnownMapiDotNETException(e) || e is AmServerException || e is ObjectNotFoundException || base.IsKnownException(e)); }
private static void InternalUpdateRecipients(IEnumerator <ADRecipient> pagedReaderGC, AddressBookBase abb, QueryFilter removeFilter, List <Guid> abbObjectGuidList, string domainControllerFqdn, IRecipientSession globalCatalogSession, Task.TaskWarningLoggingDelegate writeWarning, WriteProgress writeProgress, Cmdlet cmdlet, ref int currentPercent) { if (cmdlet != null && cmdlet.Stopping) { return; } string domainControllerDomainName = null; if (!string.IsNullOrEmpty(domainControllerFqdn)) { int num = domainControllerFqdn.IndexOf("."); if (0 <= num) { domainControllerDomainName = domainControllerFqdn.Substring(num + 1); } } IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, globalCatalogSession.SessionSettings, 300, "InternalUpdateRecipients", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AddressBook\\UpdateAddressBook.cs"); tenantOrRootOrgRecipientSession.EnforceDefaultScope = false; tenantOrRootOrgRecipientSession.EnforceContainerizedScoping = false; string text = null; while (pagedReaderGC.MoveNext()) { ADRecipient adrecipient = pagedReaderGC.Current; if (cmdlet != null && cmdlet.Stopping) { return; } ADRecipient adrecipient2 = adrecipient; try { SystemConfigurationTasksHelper.PrepareDomainControllerRecipientSessionForUpdate(tenantOrRootOrgRecipientSession, adrecipient.Id, domainControllerFqdn, domainControllerDomainName); tenantOrRootOrgRecipientSession.LinkResolutionServer = null; IConfigurable configurable = null; if (abb != null) { IEnumerator <ADRecipient> enumerator = abb.FindUpdatingRecipientsPaged(tenantOrRootOrgRecipientSession, adrecipient.Id).GetEnumerator(); if (enumerator.MoveNext()) { configurable = enumerator.Current; } } else { IConfigurable[] array = tenantOrRootOrgRecipientSession.Find(adrecipient.Id, QueryScope.Base, removeFilter, null, 1); if (array.Length > 0) { configurable = array[0]; } } if (configurable != null) { adrecipient2 = (ADRecipient)configurable; if (!adrecipient2.IsValid || adrecipient2.IsReadOnly) { writeWarning(Strings.ErrorCannotUpdateInvalidRecipient(adrecipient2.Id.ToString())); } else { if (cmdlet != null && cmdlet.Stopping) { break; } bool flag = false; if (abb != null) { using (MultiValuedProperty <ADObjectId> .Enumerator enumerator2 = adrecipient2.AddressListMembership.GetEnumerator()) { while (enumerator2.MoveNext()) { ADObjectId adobjectId = enumerator2.Current; if (ADObjectId.Equals(adobjectId, abb.Id)) { flag = true; adrecipient2.AddressListMembership.Remove(adobjectId); break; } } goto IL_1E5; } } int num2 = adrecipient2.AddressListMembership.Count - 1; while (0 <= num2) { if (abbObjectGuidList.BinarySearch(adrecipient2.AddressListMembership[num2].ObjectGuid) >= 0) { flag = true; adrecipient2.AddressListMembership.RemoveAt(num2); } num2--; } IL_1E5: if (!flag && !adrecipient2.HiddenFromAddressListsEnabled) { if (string.IsNullOrEmpty(text)) { try { if (!string.IsNullOrEmpty(abb.OriginatingServer)) { text = SystemConfigurationTasksHelper.GetConfigurationDomainControllerFqdn(abb.OriginatingServer); } } catch (SocketException ex) { writeWarning(Strings.ErrorResolveFqdnForDomainController(abb.OriginatingServer, ex.Message)); continue; } } tenantOrRootOrgRecipientSession.LinkResolutionServer = text; adrecipient2.AddressListMembership.Add(abb.Id); } currentPercent = currentPercent++ % 99 + 1; writeProgress(Strings.ProgressActivityUpdateRecipient, Strings.ProgressStatusUpdateRecipient(adrecipient2.Id.ToString()), currentPercent); tenantOrRootOrgRecipientSession.Save(adrecipient2); } } } catch (DataSourceTransientException ex2) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex2.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex2.Message }); } catch (DataSourceOperationException ex3) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex3.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex3.Message }); } catch (DataValidationException ex4) { writeWarning(Strings.ErrorUpdateRecipient(adrecipient2.Id.ToString(), ex4.Message)); TaskLogger.Trace("Exception is raised while updating recipient '{0}': {1}", new object[] { adrecipient2.Id.ToString(), ex4.Message }); } } }