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();
        }
Ejemplo n.º 2
0
 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();
 }
Ejemplo n.º 3
0
        private static ProvisioningValidationError[] ValidateUserScopeImpl(Task task)
        {
            if (ProvisioningLayer.Disabled || !task.IsProvisioningLayerAvailable)
            {
                return(null);
            }
            List <ProvisioningValidationError> list = new List <ProvisioningValidationError>();

            for (int i = 0; i < task.ProvisioningHandlers.Length; i++)
            {
                using (new CmdletMonitoredScope(task.CurrentTaskContext.UniqueId, task.ProvisioningHandlers[i].AgentName, "ValidateUserScope", LoggerHelper.CmdletPerfMonitors))
                {
                    ProvisioningValidationError[] array = task.ProvisioningHandlers[i].ValidateUserScope();
                    if (array != null && array.Length > 0)
                    {
                        for (int j = 0; j < array.Length; j++)
                        {
                            array[j].AgentName = task.ProvisioningHandlers[i].AgentName;
                        }
                        list.AddRange(array);
                        if (task.IsVerboseOn)
                        {
                            task.WriteVerbose(TaskVerboseStringHelper.GetProvisioningValidationErrors(array, i));
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Ejemplo n.º 4
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.RootId != null)
            {
                try
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(TDataObject), this.InternalFilter, this.RootId, this.DeepSearch));
                    LocalizedString?          localizedString;
                    IEnumerable <TDataObject> objects = new DatabaseIdParameter
                    {
                        AllowInvalid = true
                    }.GetObjects <TDataObject>(this.RootId, base.DataSession, base.OptionalIdentityData, out localizedString);
                    this.WriteResult <TDataObject>(objects);
                    goto IL_7E;
                }
                catch (DataSourceTransientException exception)
                {
                    base.WriteError(exception, ErrorCategory.ReadError, null);
                    goto IL_7E;
                }
            }
            base.InternalProcessRecord();
IL_7E:
            TaskLogger.LogExit();
        }
Ejemplo n.º 5
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()
            });
        }
Ejemplo n.º 6
0
 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);
     }
 }
        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 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);
 }
        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));
                }
            }
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     this.mailboxSettingOnlyPolicyIgnored = false;
     base.InternalProcessRecord();
     if (this.Identity == null && !this.IncludeMailboxSettingOnlyPolicy.IsPresent)
     {
         try
         {
             this.mailboxSettingOnlyPolicyIgnored = true;
             QueryFilter filter = new ComparisonFilter(ComparisonOperator.NotEqual, EmailAddressPolicySchema.PolicyOptionListValue, EmailAddressPolicy.PolicyGuid.ToByteArray());
             base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(EmailAddressPolicy), filter, this.RootId, this.DeepSearch));
             EmailAddressPolicy[] array = (base.DataSession as IConfigurationSession).Find <EmailAddressPolicy>((ADObjectId)this.RootId, this.DeepSearch ? QueryScope.SubTree : QueryScope.OneLevel, filter, null, 1);
             this.mailboxSettingOnlyPolicyIgnored = (0 != array.Length);
         }
         catch (DataSourceTransientException ex)
         {
             base.WriteVerbose(ex.LocalizedString);
         }
         catch (DataSourceOperationException ex2)
         {
             base.WriteVerbose(ex2.LocalizedString);
         }
     }
     if (this.mailboxSettingOnlyPolicyIgnored)
     {
         this.WriteWarning(Strings.WarningIgnoreMailboxSettingOnlyPolicy);
     }
     TaskLogger.LogExit();
 }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter(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();
 }
Ejemplo n.º 13
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     base.WriteVerbose(TaskVerboseStringHelper.GetDeleteObjectVerboseString(this.recipient.Identity, base.DataSession, typeof(ADMicrosoftExchangeRecipient)));
     base.DataSession.Delete(this.recipient);
     TaskLogger.LogExit();
 }
        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));
            }
        }
Ejemplo n.º 15
0
        protected override void InternalProcessRecord()
        {
            if (((IConfigurationSession)base.DataSession).GetOrgContainer().OrganizationId == OrganizationId.ForestWideOrgId)
            {
                base.InternalProcessRecord();
                return;
            }
            if (this.Identity == null)
            {
                base.InternalProcessRecord();
                try
                {
                    base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.GlobalConfigSession, typeof(ActiveSyncDeviceAccessRule), this.InternalFilter, base.GlobalConfigSession.GetOrgContainerId(), this.DeepSearch));
                    IEnumerable <ActiveSyncDeviceAccessRule> dataObjects = base.GlobalConfigSession.FindPaged <ActiveSyncDeviceAccessRule>(base.GlobalConfigSession.GetOrgContainerId(), QueryScope.SubTree, this.InternalFilter, this.InternalSortBy, this.PageSize);
                    this.WriteResult <ActiveSyncDeviceAccessRule>(dataObjects);
                    return;
                }
                catch (DataSourceTransientException exception)
                {
                    base.WriteError(exception, (ErrorCategory)1002, null);
                    return;
                }
            }
            LocalizedString?localizedString;
            IEnumerable <ActiveSyncDeviceAccessRule> dataObjects2 = base.GetDataObjects <ActiveSyncDeviceAccessRule>(this.Identity, base.GlobalConfigSession, base.GlobalConfigSession.GetOrgContainerId(), base.OptionalIdentityData, out localizedString);

            this.WriteResult <ActiveSyncDeviceAccessRule>(dataObjects2);
            if (!base.HasErrors && base.WriteObjectCount == 0U)
            {
                base.InternalProcessRecord();
            }
        }
 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));
         }
     }
 }
Ejemplo n.º 17
0
        protected override IEnumerable <RemovedMailbox> GetPagedData()
        {
            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(RemovedMailbox), this.InternalFilter, null, this.DeepSearch));
            RemovedMailboxIdParameter removedMailboxIdParameter = new RemovedMailboxIdParameter("*");

            return(removedMailboxIdParameter.GetObjects <RemovedMailbox>(this.RootId, base.DataSession));
        }
Ejemplo n.º 18
0
 protected void SaveDerivedRoleAndWarnOnValidationErrors(ExchangeRole role)
 {
     if (role.IsRootRole)
     {
         throw new ArgumentNullException("Only derive roles should be");
     }
     try
     {
         int count = role.RoleEntries.Count;
         ValidationError[] array = role.Validate();
         role.AllowEmptyRole = true;
         this.settings.ConfigurationSession.Save(role);
         this.settings.LogWriteObject(role);
         this.settings.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(role, this.settings.ConfigurationSession, typeof(ExchangeRole)));
         if (array != null && array.Length != 0)
         {
             this.settings.WriteWarning(Strings.WarningInvalidRoleAfterUpgrade(role.Identity.ToString(), MultiValuedPropertyBase.FormatMultiValuedProperty(array)));
         }
     }
     catch (DataSourceOperationException ex)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex.Message));
     }
     catch (DataValidationException ex2)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex2.Message));
     }
 }
Ejemplo n.º 19
0
        protected void SaveRoleAndSuggestCleanupOnFailure(ExchangeRole role)
        {
            Exception ex = null;

            try
            {
                this.settings.ConfigurationSession.Save(role);
                this.settings.LogWriteObject(role);
                this.settings.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(role, this.settings.ConfigurationSession, typeof(ExchangeRole)));
            }
            catch (DataSourceOperationException ex2)
            {
                ex = ex2;
            }
            catch (DataValidationException ex3)
            {
                ex = ex3;
            }
            if (ex != null)
            {
                CorruptedRoleNeedsCleanupException ex4 = new CorruptedRoleNeedsCleanupException(role.Identity.ToString(), ex.Message, ex);
                if (!this.settings.Task.Stopping)
                {
                    TaskLogger.SendWatsonReport(ex4);
                }
                this.settings.WriteError(ex4, ErrorCategory.InvalidOperation, null);
            }
        }
        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);
        }
Ejemplo n.º 21
0
 protected override IEnumerable <ReducedRecipient> GetPagedData()
 {
     if (this.usingALbasedVlv)
     {
         base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsInALVerboseString(base.DataSession, typeof(ReducedRecipient), this.addressList));
         return(ADVlvPagedReader <ReducedRecipient> .GetADVlvPagedReader(this.addressList, (IRecipientSession)base.DataSession, this.InternalSortBy, this.IncludeBookmarkObject, true, this.PageSize, 1, this.BookmarkDisplayName, this.propertiesToRead));
     }
     base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ReducedRecipient), this.InternalFilter, this.RootId, this.DeepSearch));
     return(((IRecipientSession)base.DataSession).FindPaged <ReducedRecipient>((ADObjectId)this.RootId, this.DeepSearch ? QueryScope.SubTree : QueryScope.OneLevel, this.InternalFilter, this.InternalSortBy, this.PageSize, this.propertiesToRead));
 }
Ejemplo n.º 22
0
        protected override IEnumerable <PolicyStorage> GetPagedData()
        {
            QueryFilter internalFilter = this.InternalFilter;

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(PolicyStorage), internalFilter, this.RootId, this.DeepSearch));
            IEnumerable <PolicyStorage> source = base.DataSession.FindPaged <PolicyStorage>(internalFilter, this.RootId, this.DeepSearch, this.InternalSortBy, this.PageSize);

            return(from dataObj in source
                   where dataObj.Scenario == PolicyScenario.DeviceSettings || dataObj.Scenario == PolicyScenario.DeviceConditionalAccess || dataObj.Scenario == PolicyScenario.DeviceTenantConditionalAccess
                   select dataObj);
        }
Ejemplo n.º 23
0
        private void CloneRoleAssignment(ExchangeRoleAssignment templateAssignment)
        {
            ExchangeRoleAssignment exchangeRoleAssignment = new ExchangeRoleAssignment();

            exchangeRoleAssignment.ProvisionalClone(templateAssignment);
            exchangeRoleAssignment.User = this.originalUserId;
            string unescapedCommonName = templateAssignment.Name.Substring(0, Math.Min(templateAssignment.Name.Length, 55)) + "_" + (Environment.TickCount % 1000).ToString("0000");

            exchangeRoleAssignment.SetId(templateAssignment.Id.Parent.GetChildId(unescapedCommonName));
            base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(exchangeRoleAssignment, templateAssignment.Session, typeof(ExchangeRoleAssignment)));
            templateAssignment.Session.Save(exchangeRoleAssignment);
        }
Ejemplo n.º 24
0
 protected override IEnumerable <ADContact> GetPagedData()
 {
     if (base.ParameterSetName == "CookieSet")
     {
         base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADContact), this.InternalFilter, this.RootId, this.DeepSearch));
         base.InternalResultSize = Unlimited <uint> .UnlimitedValue;
         ADPagedReader <ADContact> adpagedReader = (ADPagedReader <ADContact>)base.DataSession.FindPaged <ADContact>(this.InternalFilter, this.RootId, this.DeepSearch, this.InternalSortBy, this.PageSize);
         adpagedReader.Cookie = this.inputCookie.PageCookie;
         return(adpagedReader);
     }
     return(base.GetPagedData());
 }
Ejemplo n.º 25
0
        private bool LegacyDNIsUnique(string legacyDN)
        {
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.LegacyExchangeDN, legacyDN),
                new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, this.DataObject.Id)
            });

            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.TenantGlobalCatalogSession, typeof(ADRecipient), filter, null, true));
            ADRecipient[] array = base.TenantGlobalCatalogSession.Find(null, QueryScope.SubTree, filter, null, 1);
            return(0 == array.Length);
        }
Ejemplo n.º 26
0
        internal static string GenerateUniqueRoleAssignmentName(IConfigurationSession configurationSession, ADObjectId orgContainerId, string roleName, string roleAssigneeName, RoleAssignmentDelegationType roleAssignmentDelegationType, Task.TaskVerboseLoggingDelegate writeVerbose)
        {
            if (configurationSession == null)
            {
                throw new ArgumentNullException("configurationSession");
            }
            if (orgContainerId == null)
            {
                throw new ArgumentNullException("orgContainerId");
            }
            string text = roleName + "-" + roleAssigneeName;

            if (roleAssignmentDelegationType != RoleAssignmentDelegationType.Regular)
            {
                text += "-Delegating";
            }
            text = text.Trim();
            if (text.Length > 64)
            {
                text = text.Substring(0, 64).Trim();
            }
            if (writeVerbose == null)
            {
                throw new ArgumentNullException("writeVerbose");
            }
            ADObjectId descendantId = orgContainerId.GetDescendantId(ExchangeRoleAssignment.RdnContainer);
            string     text2        = text;

            if (text2.Length > 61)
            {
                text2 = text2.Substring(0, 61).Trim();
            }
            int num = 1;

            for (;;)
            {
                QueryFilter filter = new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, text);
                writeVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(configurationSession, typeof(ExchangeRoleAssignment), filter, descendantId, false));
                ExchangeRoleAssignment[] array = configurationSession.Find <ExchangeRoleAssignment>(descendantId, QueryScope.OneLevel, filter, null, 1);
                if (array.Length == 0)
                {
                    break;
                }
                text = text2 + "-" + num.ToString();
                num++;
                if (num >= 100)
                {
                    return(text);
                }
            }
            return(text);
        }
        protected override IEnumerable <ADRawEntry> GetPagedData()
        {
            if (this.Cookie == null)
            {
                DeletedRecipient item = new DeletedRecipient();
                return(new List <ADRawEntry>
                {
                    item
                });
            }
            PropertyDefinition[] properties = new PropertyDefinition[]
            {
                ADObjectSchema.Id,
                ADObjectSchema.Name,
                ADObjectSchema.DistinguishedName,
                ADObjectSchema.Guid,
                ADObjectSchema.OrganizationalUnitRoot,
                ADObjectSchema.ObjectClass,
                ADObjectSchema.WhenChanged,
                ADObjectSchema.WhenChangedUTC,
                ADObjectSchema.WhenCreated,
                ADObjectSchema.WhenCreatedUTC
            };
            if (this.requireTwoQueries)
            {
                IRecipientSession sessionForSoftDeletedObjects = SoftDeletedTaskHelper.GetSessionForSoftDeletedObjects(base.CurrentOrganizationId, this.DomainController);
                ADObjectId        childId     = base.CurrentOrganizationId.OrganizationalUnit.GetChildId("OU", "Soft Deleted Objects");
                QueryFilter       queryFilter = new ComparisonFilter(ComparisonOperator.Equal, ADRecipientSchema.IsSoftDeletedByRemove, true);
                queryFilter = new AndFilter(new QueryFilter[]
                {
                    queryFilter,
                    SyncTaskHelper.GetDeltaFilter(this.inputCookie)
                });
                this.reader2        = sessionForSoftDeletedObjects.FindPagedADRawEntry(childId, QueryScope.OneLevel, queryFilter, null, this.PageSize, properties);
                this.reader2.Cookie = this.inputCookie.PageCookie2;
                base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(sessionForSoftDeletedObjects, typeof(ADRawEntry), queryFilter, null, false));
            }
            IRecipientSession recipientSession        = (IRecipientSession)base.DataSession;
            ADObjectId        deletedObjectsContainer = ADSession.GetDeletedObjectsContainer(recipientSession.GetDomainNamingContext());
            QueryFilter       internalFilter          = this.InternalFilter;

            recipientSession.SessionSettings.SkipCheckVirtualIndex = true;
            ADPagedReader <ADRawEntry> adpagedReader = recipientSession.FindPagedADRawEntry(deletedObjectsContainer, QueryScope.OneLevel, internalFilter, null, this.PageSize, properties);

            adpagedReader.IncludeDeletedObjects = true;
            adpagedReader.Cookie = this.inputCookie.PageCookie;
            base.WriteVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(base.DataSession, typeof(ADRawEntry), this.InternalFilter, null, false));
            return(adpagedReader);
        }
Ejemplo n.º 28
0
        // Token: 0x06001209 RID: 4617 RVA: 0x0003817C File Offset: 0x0003637C
        internal static Server FindMailboxServer(string domainController, OfflineAddressBook currentOABSettings, LogMessageDelegate logger)
        {
            ITopologyConfigurationSession topologyConfigurationSession = PhysicalResourceLoadBalancing.CreateGlobalConfigSession(domainController);
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.GreaterThanOrEqual, ServerSchema.VersionNumber, Server.E14MinVersion),
                new BitMaskAndFilter(ServerSchema.CurrentServerRole, 2UL),
                new ComparisonFilter(ComparisonOperator.Equal, ActiveDirectoryServerSchema.IsExcludedFromProvisioning, false)
            });

            PhysicalResourceLoadBalancing.LogVerbose(TaskVerboseStringHelper.GetFindDataObjectsVerboseString(topologyConfigurationSession, typeof(Server), filter, null, true), logger);
            ADPagedReader <Server> adpagedReader = topologyConfigurationSession.FindPaged <Server>(null, QueryScope.SubTree, filter, null, 0);
            List <Server>          list          = new List <Server>();

            foreach (Server server in adpagedReader)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbFoundMailboxServer(server.Identity.ToString()), logger);
                list.Add(server);
            }
            if (currentOABSettings.Server != null)
            {
                Server currentOABServer = topologyConfigurationSession.Read <Server>(currentOABSettings.Server);
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOABIsCurrentlyOnServer((currentOABServer == null) ? Strings.VerboseLbDeletedServer : currentOABServer.Identity.ToString()), logger);
                if (currentOABServer != null && list.Find((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id)) != null)
                {
                    if (list.Count == 1)
                    {
                        PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbOnlyOneEligibleServer(currentOABServer.Identity.ToString()), logger);
                        return(currentOABServer);
                    }
                    list.RemoveAll((Server s) => ADObjectId.Equals(s.Id, currentOABServer.Id));
                }
            }
            if (list.Count == 0)
            {
                PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbNoEligibleServers, logger);
                return(null);
            }
            if (list.Count == 1)
            {
                return(list[0]);
            }
            Random random  = new Random();
            Server server2 = list[random.Next(0, list.Count)];

            PhysicalResourceLoadBalancing.LogVerbose(Strings.VerboseLbReturningServer(server2.Identity.ToString()), logger);
            return(server2);
        }
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            IConfigurationSession configurationSession  = (IConfigurationSession)base.DataSession;
            OrganizationId        currentOrganizationId = (this.Identity != null) ? this.DataObject.OrganizationId : base.CurrentOrganizationId;
            ADSessionSettings     sessionSettings       = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, currentOrganizationId, base.ExecutingUserOrganizationId, false);

            configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(configurationSession.DomainController, false, ConsistencyMode.PartiallyConsistent, configurationSession.NetworkCredential, sessionSettings, 62, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\DisableAddressListPaging.cs");
            Organization orgContainer = configurationSession.GetOrgContainer();

            if (orgContainer.IsAddressListPagingEnabled)
            {
                orgContainer.IsAddressListPagingEnabled = false;
                base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(orgContainer, configurationSession, typeof(Organization)));
                configurationSession.Save(orgContainer);
            }
        }
Ejemplo n.º 30
0
 protected void SaveRoleAndWarnOnFailure(ExchangeRole role)
 {
     try
     {
         this.settings.ConfigurationSession.Save(role);
         this.settings.LogWriteObject(role);
         this.settings.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(role, this.settings.ConfigurationSession, typeof(ExchangeRole)));
     }
     catch (DataSourceOperationException ex)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex.Message));
     }
     catch (DataValidationException ex2)
     {
         this.settings.WriteWarning(Strings.WarningCannotUpgradeRole(role.Identity.ToString(), ex2.Message));
     }
 }