示例#1
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            AddressBookBase dataObject = base.DataObject;

            if (dataObject.CheckForAssociatedAddressBookPolicies() && !this.HandleRemoveWithAssociatedAddressBookPolicies())
            {
                return;
            }
            ADObjectId id = base.DataObject.Id;

            base.InternalProcessRecord();
            if (!base.HasErrors)
            {
                try
                {
                    ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, base.DataObject.OrganizationId, base.ExecutingUserOrganizationId, false);
                    IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.TenantGlobalCatalogSession.DomainController, true, ConsistencyMode.PartiallyConsistent, sessionSettings, 99, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AddressBook\\RemoveAddressBook.cs");
                    tenantOrRootOrgRecipientSession.UseGlobalCatalog = true;
                    UpdateAddressBookBase <AddressListIdParameter> .UpdateRecipients(base.DataObject, new ADObjectId[]
                    {
                        base.DataObject.Id
                    }, base.DomainController, tenantOrRootOrgRecipientSession, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new WriteProgress(base.WriteProgress), this);
                }
                catch (DataSourceTransientException ex)
                {
                    TIdParameter identity = this.Identity;
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(identity.ToString(), base.DataObject.LdapRecipientFilter, ex.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients: {0}", new object[]
                    {
                        ex.ToString()
                    });
                }
                catch (DataSourceOperationException ex2)
                {
                    TIdParameter identity2 = this.Identity;
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(identity2.ToString(), base.DataObject.LdapRecipientFilter, ex2.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients matching filter: {0}", new object[]
                    {
                        ex2.ToString()
                    });
                }
            }
            TaskLogger.LogExit();
        }
示例#2
0
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         ADSessionSettings sessionSettings = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, this.DataObject.OrganizationId, base.ExecutingUserOrganizationId, false);
         IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.TenantGlobalCatalogSession.DomainController, true, ConsistencyMode.PartiallyConsistent, sessionSettings, 459, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\AddressBook\\UpdateAddressBook.cs");
         tenantOrRootOrgRecipientSession.UseGlobalCatalog = true;
         UpdateAddressBookBase <TIdParameter> .UpdateRecipients(this.DataObject, base.DomainController, tenantOrRootOrgRecipientSession, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new WriteProgress(base.WriteProgress), this);
     }
     catch (DataSourceTransientException ex)
     {
         TIdParameter identity = this.Identity;
         base.WriteError(new InvalidOperationException(Strings.ErrorReadMatchingRecipients(identity.ToString(), this.DataObject.LdapRecipientFilter, ex.Message), ex), ErrorCategory.InvalidOperation, this.DataObject.Id);
         TaskLogger.Trace("Exception is raised while reading recipients: {0}", new object[]
         {
             ex.ToString()
         });
     }
     catch (DataSourceOperationException ex2)
     {
         TIdParameter identity2 = this.Identity;
         base.WriteError(new InvalidOperationException(Strings.ErrorReadMatchingRecipients(identity2.ToString(), this.DataObject.LdapRecipientFilter, ex2.Message), ex2), ErrorCategory.InvalidOperation, this.DataObject.Id);
         TaskLogger.Trace("Exception is raised while reading recipients matching filter: {0}", new object[]
         {
             ex2.ToString()
         });
     }
     if (!this.DataObject.ExchangeVersion.IsOlderThan(ExchangeObjectVersion.Exchange2007))
     {
         this.DataObject[AddressBookBaseSchema.LastUpdatedRecipientFilter] = this.DataObject.RecipientFilter;
         this.DataObject[AddressBookBaseSchema.RecipientFilterApplied]     = true;
     }
     base.InternalProcessRecord();
     TaskLogger.LogExit();
 }
示例#3
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            if (this.Recursive)
            {
                IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession;
                List <ADObjectId>     list = new List <ADObjectId>();
                try
                {
                    this.currentProcent = 0;
                    ADPagedReader <AddressBookBase> adpagedReader = configurationSession.FindPaged <AddressBookBase>(base.DataObject.Id, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.NotEqual, ADObjectSchema.Id, base.DataObject.Id), null, 0);
                    foreach (AddressBookBase addressBookBase in adpagedReader)
                    {
                        list.Add(addressBookBase.Id);
                        if (list.Count % ADGenericPagedReader <AddressBookBase> .DefaultPageSize == 0)
                        {
                            this.MoveToNextPercent();
                            base.WriteProgress(Strings.ProgressActivityRemovingAddressListTree(base.DataObject.Id.ToString()), Strings.ProgressStatusReadingAddressListTree(list.Count), this.currentProcent);
                        }
                    }
                    list.Add(base.DataObject.Id);
                    if (this.currentProcent != 0)
                    {
                        this.ReportDeleteTreeProgress(null);
                    }
                    configurationSession.DeleteTree(base.DataObject, new TreeDeleteNotFinishedHandler(this.ReportDeleteTreeProgress));
                }
                catch (DataSourceTransientException exception)
                {
                    base.WriteError(exception, ErrorCategory.WriteError, base.DataObject.Identity);
                    TaskLogger.LogExit();
                    return;
                }
                try
                {
                    UpdateAddressBookBase <AddressListIdParameter> .UpdateRecipients(base.DataObject, list.ToArray(), base.DomainController, base.TenantGlobalCatalogSession, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new WriteProgress(base.WriteProgress), this);

                    goto IL_206;
                }
                catch (DataSourceTransientException ex)
                {
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(this.Identity.ToString(), base.DataObject.LdapRecipientFilter, ex.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients: {0}", new object[]
                    {
                        ex.ToString()
                    });
                    goto IL_206;
                }
                catch (DataSourceOperationException ex2)
                {
                    this.WriteWarning(Strings.ErrorReadMatchingRecipients(this.Identity.ToString(), base.DataObject.LdapRecipientFilter, ex2.Message));
                    TaskLogger.Trace("Exception is raised while reading recipients matching filter: {0}", new object[]
                    {
                        ex2.ToString()
                    });
                    goto IL_206;
                }
            }
            base.InternalProcessRecord();
IL_206:
            TaskLogger.LogExit();
        }
示例#4
0
        protected override void InternalProcessRecord()
        {
            TaskLogger.LogEnter();
            IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession;
            OrganizationId        organizationId       = (this.Identity != null) ? this.DataObject.OrganizationId : base.CurrentOrganizationId;
            ADSessionSettings     sessionSettings      = ADSessionSettings.FromOrganizationIdWithoutRbacScopes(base.RootOrgContainerId, organizationId, base.ExecutingUserOrganizationId, false);

            configurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(configurationSession.DomainController, false, ConsistencyMode.PartiallyConsistent, configurationSession.NetworkCredential, sessionSettings, 102, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\EnableAddressListPaging.cs");
            ADObjectId descendantId;

            if (organizationId != OrganizationId.ForestWideOrgId)
            {
                descendantId = organizationId.ConfigurationUnit.GetDescendantId(SystemAddressList.RdnSystemAddressListContainerToOrganization);
            }
            else
            {
                descendantId = base.RootOrgContainerId.GetDescendantId(SystemAddressList.RdnSystemAddressListContainerToOrganization);
            }
            AddressBookBase addressBookBase = configurationSession.Read <AddressBookBase>(descendantId);

            if (null == addressBookBase)
            {
                addressBookBase = new AddressBookBase();
                addressBookBase.SetId(descendantId);
                addressBookBase.DisplayName    = SystemAddressList.RdnSystemAddressListContainerToOrganization.Name;
                addressBookBase.OrganizationId = organizationId;
                configurationSession.Save(addressBookBase);
            }
            Dictionary <string, bool> dictionary;

            this.CreateCannedSystemAddressLists(configurationSession, addressBookBase, out dictionary);
            IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(base.TenantGlobalCatalogSession.DomainController, true, ConsistencyMode.PartiallyConsistent, null, sessionSettings, 146, "InternalProcessRecord", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\organization\\EnableAddressListPaging.cs");

            AddressBookBase[] array = configurationSession.Find <AddressBookBase>(descendantId, QueryScope.SubTree, null, null, 0);
            foreach (AddressBookBase addressBookBase2 in array)
            {
                if (base.Stopping)
                {
                    return;
                }
                bool flag = false;
                dictionary.TryGetValue(addressBookBase2.Name, out flag);
                if (this.DoNotUpdateRecipients.IsPresent)
                {
                    if (flag)
                    {
                        this.WriteWarning(Strings.WarningMustRunEnableAddressListPagingWithForceSwitch(addressBookBase2.Name));
                    }
                }
                else if (this.ForceUpdateOfRecipients.IsPresent || flag)
                {
                    UpdateAddressBookBase <AddressListIdParameter> .UpdateRecipients(addressBookBase2, base.DomainController, tenantOrRootOrgRecipientSession, new Task.TaskWarningLoggingDelegate(this.WriteWarning), new WriteProgress(base.WriteProgress), this);
                }
            }
            Organization orgContainer = configurationSession.GetOrgContainer();

            if (!orgContainer.IsAddressListPagingEnabled)
            {
                orgContainer.IsAddressListPagingEnabled = true;
                base.WriteVerbose(TaskVerboseStringHelper.GetSaveObjectVerboseString(orgContainer, configurationSession, typeof(Organization)));
                configurationSession.Save(orgContainer);
            }
            TaskLogger.LogExit();
        }
示例#5
0
        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);
            }
        }
示例#6
0
 internal static void UpdateRecipients(AddressBookBase abb, string domainController, IRecipientSession globalCatalogSession, Task.TaskWarningLoggingDelegate writeWarning, WriteProgress writeProgress, Cmdlet cmdlet)
 {
     UpdateAddressBookBase <TIdParameter> .UpdateRecipients(abb, null, domainController, globalCatalogSession, writeWarning, writeProgress, cmdlet);
 }