예제 #1
0
        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);
        }
예제 #3
0
 internal ADSite GetADSite(AdSiteIdParameter siteId, ITopologyConfigurationSession session, DataAccessHelper.GetDataObjectDelegate getDataObject)
 {
     this.writeVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(siteId, session, typeof(ADSite), session.GetConfigurationNamingContext().GetChildId("Sites")));
     return((ADSite)getDataObject(siteId, session, null, null, new LocalizedString?(Strings.ErrorSiteNotFound(siteId.ToString())), new LocalizedString?(Strings.ErrorSiteNotUnique(siteId.ToString()))));
 }
예제 #4
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(new object[]
     {
         this.DataObject
     });
     try
     {
         try
         {
             MailboxDatabase mailboxDatabase  = this.ConfigurationSession.Read <MailboxDatabase>((ADObjectId)this.DataObject.Identity);
             Server          server           = null;
             ADComputer      adcomputer       = null;
             bool            useConfigNC      = this.ConfigurationSession.UseConfigNC;
             bool            useGlobalCatalog = this.ConfigurationSession.UseGlobalCatalog;
             if (mailboxDatabase != null)
             {
                 server = mailboxDatabase.GetServer();
                 try
                 {
                     this.ConfigurationSession.UseConfigNC      = false;
                     this.ConfigurationSession.UseGlobalCatalog = true;
                     adcomputer = ((ITopologyConfigurationSession)this.ConfigurationSession).FindComputerByHostName(server.Name);
                 }
                 finally
                 {
                     this.ConfigurationSession.UseConfigNC      = useConfigNC;
                     this.ConfigurationSession.UseGlobalCatalog = useGlobalCatalog;
                 }
                 if (adcomputer == null)
                 {
                     base.WriteError(new ManagementObjectNotFoundException(Strings.ErrorDBOwningServerNotFound(mailboxDatabase.Identity.ToString())), ErrorCategory.ObjectNotFound, server.Identity);
                 }
                 ADObjectId adobjectId = adcomputer.Id.DomainId;
                 adobjectId = adobjectId.GetChildId("Microsoft Exchange System Objects");
                 adobjectId = adobjectId.GetChildId("SystemMailbox" + mailboxDatabase.Guid.ToString("B"));
                 string identity = adobjectId.ToDNString();
                 GeneralMailboxIdParameter generalMailboxIdParameter = GeneralMailboxIdParameter.Parse(identity);
                 base.WriteVerbose(TaskVerboseStringHelper.GetFindByIdParameterVerboseString(generalMailboxIdParameter, this.RecipientSession, typeof(ADRecipient), null));
                 IEnumerable <ADSystemMailbox> objects = generalMailboxIdParameter.GetObjects <ADSystemMailbox>(adobjectId, this.RecipientSession);
                 using (IEnumerator <ADSystemMailbox> enumerator = objects.GetEnumerator())
                 {
                     if (enumerator.MoveNext())
                     {
                         ADSystemMailbox adsystemMailbox = enumerator.Current;
                     }
                     else
                     {
                         NewMailboxDatabase.SaveSystemMailbox(mailboxDatabase, mailboxDatabase.GetServer(), base.RootOrgContainerId, (ITopologyConfigurationSession)this.ConfigurationSession, this.RecipientSession, null, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new Task.TaskVerboseLoggingDelegate(base.WriteVerbose));
                     }
                 }
             }
             base.WriteVerbose(Strings.VerboseMountDatabase(this.Identity.ToString()));
             this.RequestMount(MountFlags.None);
             if (!this.DataObject.DatabaseCreated)
             {
                 this.DataObject.DatabaseCreated = true;
                 base.InternalProcessRecord();
             }
         }
         catch (AmServerException ex)
         {
             Exception ex2;
             if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 TaskLogger.Trace("Database already mounted (database={0}, exception={1})", new object[]
                 {
                     this.DataObject.Name,
                     ex2.Message
                 });
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2) || ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.AttemptForcedMountIfNecessary(this.Force, Strings.ContinueMountWhenDBFilesNotExist, Strings.VerboseMountDatabaseForcely(this.Identity.ToString()), Strings.ErrorFailedToMountReplicatedDbWithMissingEdbFile(this.Identity.ToString()), ex, MountFlags.ForceDatabaseCreation);
             }
             else if (ex.TryGetInnerExceptionOfType(out ex2))
             {
                 this.PromptForMountIfNecessary(this.AcceptDataLoss, Strings.ContinueMountWithDataLoss, Strings.VerboseMountDatabaseDataLoss(this.Identity.ToString()), MountFlags.AcceptDataLoss);
             }
             else
             {
                 TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
                 {
                     ex.Message
                 });
                 base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex.Message), ex), ErrorCategory.InvalidOperation, this.DataObject.Identity);
             }
         }
     }
     catch (AmServerException ex3)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex3.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex3.Message), ex3), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     catch (AmServerTransientException ex4)
     {
         TaskLogger.Trace("MountDatabase.InternalProcessRecord raises exception while mounting database: {0}", new object[]
         {
             ex4.Message
         });
         base.WriteError(new InvalidOperationException(Strings.ErrorFailedToMountDatabase(this.Identity.ToString(), ex4.Message), ex4), ErrorCategory.InvalidOperation, this.DataObject.Identity);
     }
     finally
     {
         TaskLogger.LogExit();
     }
 }