Пример #1
0
        public AcceptedDomain GetAcceptedDomainByDomainName(string domainName)
        {
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                ADObject.ObjectClassFilter("msExchAcceptedDomain"),
                new ComparisonFilter(ComparisonOperator.Equal, AcceptedDomainSchema.DomainName, domainName)
            });

            AcceptedDomain[] array = base.Find <AcceptedDomain>(null, QueryScope.SubTree, filter, null, 2);
            if (array == null || array.Length == 0)
            {
                return(null);
            }
            if (array.Length == 2)
            {
                throw new ADOperationException(DirectoryStrings.DuplicatedAcceptedDomain(domainName, array[0].Id.ToDNString(), array[1].Id.ToDNString()));
            }
            return(array[0]);
        }
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            AvailabilityConfig    availabilityConfig   = null;
            IConfigurationSession configurationSession = (IConfigurationSession)base.DataSession;
            ADObjectId            orgContainerId       = configurationSession.GetOrgContainerId();

            configurationSession.SessionSettings.IsSharedConfigChecked = true;
            AvailabilityConfig[] array = configurationSession.Find <AvailabilityConfig>(orgContainerId, QueryScope.SubTree, ADObject.ObjectClassFilter("msExchAvailabilityConfig"), null, 1);
            if (array != null && array.Length == 1)
            {
                availabilityConfig = array[0];
            }
            if (availabilityConfig == null)
            {
                availabilityConfig = (AvailabilityConfig)base.PrepareDataObject();
            }
            availabilityConfig.Name = AvailabilityConfig.ContainerName;
            availabilityConfig.SetId((IConfigurationSession)base.DataSession, availabilityConfig.Name);
            availabilityConfig.OrgWideAccount = this.ValidateUser((SecurityPrincipalIdParameter)base.Fields["OrgWideAccount"]);
            ADDomain addomain = ADForest.GetLocalForest().FindRootDomain(true);

            if (addomain == null)
            {
                base.ThrowTerminatingError(new RootDomainNotFoundException(), ErrorCategory.InvalidData, null);
            }
            IRecipientSession     tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(addomain.OriginatingServer, false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 105, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs");
            IConfigurationSession configurationSession2           = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 111, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs");

            this.exchangeServerGroup = null;
            try
            {
                this.exchangeServerGroup = tenantOrRootOrgRecipientSession.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, configurationSession2.ConfigurationNamingContext);
            }
            catch (ADReferralException)
            {
            }
            if (this.exchangeServerGroup == null)
            {
                IRecipientSession tenantOrRootOrgRecipientSession2 = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(false, ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 131, "PrepareDataObject", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Management\\SystemConfigurationTasks\\Availability\\NewAvailabilityConfig.cs");
                tenantOrRootOrgRecipientSession2.UseGlobalCatalog = true;
                this.exchangeServerGroup = tenantOrRootOrgRecipientSession2.ResolveWellKnownGuid <ADGroup>(WellKnownGuid.ExSWkGuid, configurationSession2.ConfigurationNamingContext);
            }
            if (this.exchangeServerGroup == null)
            {
                base.ThrowTerminatingError(new ExSGroupNotFoundException(WellKnownGuid.ExSWkGuid), ErrorCategory.InvalidData, null);
            }
            TaskLogger.LogExit();
            return(availabilityConfig);
        }
Пример #3
0
 private static QueryFilter[] InitializeStaticRecipientTypeFilters()
 {
     QueryFilter[] array = new QueryFilter[Filters.RecipientTypeCount];
     array[1] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectClassFilter(ADUser.MostDerivedClass, true),
         ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
         Filters.CreateMailEnabledFilter(false)
     });
     array[2] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectClassFilter(ADUser.MostDerivedClass, true),
         ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
         Filters.CreateMailEnabledFilter(true),
         Filters.CreateMailboxEnabledFilter(true)
     });
     array[3] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectClassFilter(ADUser.MostDerivedClass, true),
         ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
         Filters.CreateMailEnabledFilter(true),
         Filters.CreateMailboxEnabledFilter(false)
     });
     array[4] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectClassFilter(ADContact.MostDerivedClass),
         Filters.CreateMailEnabledFilter(false)
     });
     array[5] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectClassFilter(ADContact.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[6] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
         Filters.CreateMailEnabledFilter(false)
     });
     array[9] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
         Filters.NonUniversalGroupFilter,
         Filters.CreateMailEnabledFilter(true)
     });
     array[7] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
         Filters.UniversalDistributionGroupFilter,
         Filters.CreateMailEnabledFilter(true)
     });
     array[8] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
         Filters.UniversalSecurityGroupFilter,
         Filters.CreateMailEnabledFilter(true)
     });
     array[10] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADDynamicGroup.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[11] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADPublicFolder.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[12] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADPublicDatabase.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[13] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADSystemAttendantMailbox.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[15] = new AndFilter(new QueryFilter[]
     {
         ADObject.ObjectCategoryFilter(ADMicrosoftExchangeRecipient.MostDerivedClass),
         Filters.CreateMailEnabledFilter(true)
     });
     array[14] = new AndFilter(new QueryFilter[]
     {
         Filters.CreateMailEnabledFilter(true),
         Filters.CreateMailboxEnabledFilter(true),
         new OrFilter(new QueryFilter[]
         {
             ADObject.ObjectCategoryFilter(ADSystemMailbox.MostDerivedClass),
             new AndFilter(new QueryFilter[]
             {
                 ADUser.ImplicitFilterInternal,
                 new TextFilter(ADObjectSchema.Name, "SystemMailbox{", MatchOptions.Prefix, MatchFlags.Default)
             })
         })
     });
     array[16] = ADComputerRecipient.ImplicitFilterInternal;
     return(array);
 }
Пример #4
0
        private static Dictionary <int, QueryFilter> InitializeStaticRecipientTypeFilterOptimizations()
        {
            Dictionary <int, QueryFilter> dictionary = new Dictionary <int, QueryFilter>(32);

            Filters.RecipientTypeBitVector32 recipientTypeBitVector = default(Filters.RecipientTypeBitVector32);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.DynamicDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.UserMailbox] = true;
            recipientTypeBitVector[RecipientType.MailContact] = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            recipientTypeBitVector[RecipientType.MailUser] = true;
            QueryFilter value = Filters.AllMailableUsersContactsDDLsUniversalGroupsFilter;

            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.Contact]     = true;
            recipientTypeBitVector[RecipientType.MailContact] = true;
            value = ADObject.ObjectClassFilter(ADContact.MostDerivedClass);
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.Group] = true;
            recipientTypeBitVector[RecipientType.MailNonUniversalGroup]          = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            value = ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass);
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.MailNonUniversalGroup]          = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            value = new AndFilter(new QueryFilter[]
            {
                Filters.CreateMailEnabledFilter(true),
                ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass)
            });
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.User]        = true;
            recipientTypeBitVector[RecipientType.MailUser]    = true;
            recipientTypeBitVector[RecipientType.UserMailbox] = true;
            value = ADUser.ImplicitFilterInternal;
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.DynamicDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.UserMailbox] = true;
            recipientTypeBitVector[RecipientType.MailContact] = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            recipientTypeBitVector[RecipientType.MailUser] = true;
            recipientTypeBitVector[RecipientType.MailNonUniversalGroup] = true;
            recipientTypeBitVector[RecipientType.PublicFolder]          = true;
            value = new AndFilter(new QueryFilter[]
            {
                Filters.CreateMailEnabledFilter(true),
                new OrFilter(new QueryFilter[]
                {
                    ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
                    ADObject.ObjectCategoryFilter(ADDynamicGroup.ObjectCategoryNameInternal),
                    ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
                    ADObject.ObjectCategoryFilter(ADPublicFolder.MostDerivedClass)
                })
            });
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.DynamicDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.UserMailbox] = true;
            recipientTypeBitVector[RecipientType.MailContact] = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            recipientTypeBitVector[RecipientType.MailUser] = true;
            recipientTypeBitVector[RecipientType.MailNonUniversalGroup]  = true;
            recipientTypeBitVector[RecipientType.PublicFolder]           = true;
            recipientTypeBitVector[RecipientType.SystemAttendantMailbox] = true;
            recipientTypeBitVector[RecipientType.SystemMailbox]          = true;
            value = new AndFilter(new QueryFilter[]
            {
                Filters.CreateMailEnabledFilter(true),
                new OrFilter(new QueryFilter[]
                {
                    ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
                    ADObject.ObjectCategoryFilter(ADDynamicGroup.ObjectCategoryNameInternal),
                    ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
                    ADObject.ObjectCategoryFilter(ADPublicFolder.MostDerivedClass),
                    ADObject.ObjectCategoryFilter(ADSystemAttendantMailbox.MostDerivedClass),
                    ADObject.ObjectCategoryFilter(ADSystemMailbox.MostDerivedClass)
                })
            });
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.DynamicDistributionGroup]       = true;
            recipientTypeBitVector[RecipientType.MailUniversalDistributionGroup] = true;
            recipientTypeBitVector[RecipientType.MailUniversalSecurityGroup]     = true;
            value = new AndFilter(new QueryFilter[]
            {
                Filters.CreateMailEnabledFilter(true),
                new OrFilter(new QueryFilter[]
                {
                    ADObject.ObjectCategoryFilter(ADDynamicGroup.ObjectCategoryNameInternal),
                    new AndFilter(new QueryFilter[]
                    {
                        ADObject.ObjectCategoryFilter(ADGroup.MostDerivedClass),
                        Filters.CreateUniversalGroupFilter(true)
                    })
                })
            });
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            recipientTypeBitVector[RecipientType.MailContact] = true;
            recipientTypeBitVector[RecipientType.MailUser]    = true;
            value = new AndFilter(new QueryFilter[]
            {
                ADObject.ObjectCategoryFilter(ADUser.ObjectCategoryNameInternal),
                Filters.CreateMailEnabledFilter(true),
                new OrFilter(new QueryFilter[]
                {
                    ADObject.ObjectClassFilter(ADContact.MostDerivedClass),
                    Filters.CreateMailboxEnabledFilter(false)
                })
            });
            dictionary.Add(recipientTypeBitVector.Data, value);
            recipientTypeBitVector.Reset();
            return(dictionary);
        }
        private static QueryFilter GenerateTargetFilterForUserAndNonDomainLocalGroup(MultiValuedProperty <SecurityPrincipalType> types)
        {
            List <CompositeFilter> list = new List <CompositeFilter>();

            foreach (SecurityPrincipalType securityPrincipalType in types)
            {
                CompositeFilter compositeFilter = null;
                switch (securityPrincipalType)
                {
                case SecurityPrincipalType.User:
                    compositeFilter = new AndFilter(new QueryFilter[]
                    {
                        new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectCategory, ADUser.ObjectCategoryNameInternal),
                        ADObject.ObjectClassFilter(ADUser.MostDerivedClass, true)
                    });
                    break;

                case SecurityPrincipalType.Group:
                    compositeFilter = new AndFilter(new QueryFilter[]
                    {
                        new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.ObjectCategory, ADGroup.MostDerivedClass),
                        new BitMaskOrFilter(ADGroupSchema.GroupType, (ulong)int.MinValue),
                        new NotFilter(new BitMaskAndFilter(ADGroupSchema.GroupType, 4UL))
                    });
                    break;

                case SecurityPrincipalType.UniversalSecurityGroup:
                    if (!types.Contains(SecurityPrincipalType.Group))
                    {
                        compositeFilter = ExtendedSecurityPrincipalSearchHelper.GenerateTargetFilterForSecurityGroup(GroupTypeFlags.Universal);
                    }
                    break;

                case SecurityPrincipalType.GlobalSecurityGroup:
                    if (!types.Contains(SecurityPrincipalType.Group))
                    {
                        compositeFilter = ExtendedSecurityPrincipalSearchHelper.GenerateTargetFilterForSecurityGroup(GroupTypeFlags.Global);
                    }
                    break;
                }
                if (compositeFilter != null)
                {
                    if (Datacenter.IsMicrosoftHostedOnly(true) && (securityPrincipalType == SecurityPrincipalType.Group || securityPrincipalType == SecurityPrincipalType.UniversalSecurityGroup))
                    {
                        compositeFilter = new AndFilter(new QueryFilter[]
                        {
                            compositeFilter,
                            new OrFilter(new QueryFilter[]
                            {
                                new NotFilter(new BitMaskAndFilter(ADGroupSchema.GroupType, 8UL)),
                                new AndFilter(new QueryFilter[]
                                {
                                    new BitMaskAndFilter(ADGroupSchema.GroupType, 8UL),
                                    new OrFilter(new QueryFilter[]
                                    {
                                        new ExistsFilter(ADRecipientSchema.Alias),
                                        Filters.GetRecipientTypeDetailsFilterOptimization(RecipientTypeDetails.RoleGroup)
                                    })
                                })
                            })
                        });
                    }
                    list.Add(compositeFilter);
                }
            }
            return(new OrFilter(list.ToArray()));
        }
Пример #6
0
        protected override IConfigurable PrepareDataObject()
        {
            TaskLogger.LogEnter();
            FederatedOrganizationId federatedOrganizationId = null;
            IConfigurationSession   configurationSession    = (IConfigurationSession)base.DataSession;
            ADObjectId orgContainerId = configurationSession.GetOrgContainerId();

            configurationSession.SessionSettings.IsSharedConfigChecked = true;
            FederatedOrganizationId[] array = configurationSession.Find <FederatedOrganizationId>(orgContainerId, QueryScope.SubTree, ADObject.ObjectClassFilter("msExchFedOrgId"), null, 1);
            if (array != null && array.Length == 1)
            {
                federatedOrganizationId = array[0];
            }
            if (federatedOrganizationId != null)
            {
                if (!federatedOrganizationId.Name.Equals("Federation", StringComparison.OrdinalIgnoreCase))
                {
                    this.containerHasBeenRenamed = true;
                }
            }
            else
            {
                federatedOrganizationId = (FederatedOrganizationId)base.PrepareDataObject();
            }
            federatedOrganizationId.Name = "Federation";
            federatedOrganizationId.SetId((IConfigurationSession)base.DataSession, federatedOrganizationId.Name);
            TaskLogger.LogExit();
            return(federatedOrganizationId);
        }