public static void ValidatePartitionDN(ADRootDSE rootDSE, string partitionDN)
        {
            IEnumerable <string> partitionList;

            if (ADForestPartitionInfo.IsValidPartitionDN(rootDSE, partitionDN, false) || ADForestPartitionInfo.IsValidPartitionDN(rootDSE, partitionDN, true))
            {
                return;
            }
            else
            {
                CultureInfo currentCulture = CultureInfo.CurrentCulture;
                string      invalidPartitionMustBelongToValidSet = StringResources.InvalidPartitionMustBelongToValidSet;
                object[]    objArray  = new object[1];
                object[]    objArray1 = objArray;
                int         num       = 0;
                if (rootDSE.SessionInfo.ConnectedToGC)
                {
                    partitionList = ADForestPartitionInfo.GetForestPartitionInfo(rootDSE).PartitionList;
                }
                else
                {
                    partitionList = rootDSE.NamingContexts;
                }
                objArray1[num] = ADForestPartitionInfo.ConcatList(partitionList, " , ");
                throw new ArgumentException(string.Format(currentCulture, invalidPartitionMustBelongToValidSet, objArray));
            }
        }
        public static string ExtractAndValidatePartitionInfo(ADRootDSE rootDSE, string objectDN)
        {
            IEnumerable <string> partitionList;
            string str = ADForestPartitionInfo.ExtractPartitionInfo(rootDSE, objectDN, false);

            if (str == null)
            {
                str = ADForestPartitionInfo.ExtractPartitionInfo(rootDSE, objectDN, true);
                if (str == null)
                {
                    CultureInfo currentCulture = CultureInfo.CurrentCulture;
                    string      invalidDNMustBelongToValidPartitionSet = StringResources.InvalidDNMustBelongToValidPartitionSet;
                    object[]    objArray  = new object[1];
                    object[]    objArray1 = objArray;
                    int         num       = 0;
                    if (rootDSE.SessionInfo.ConnectedToGC)
                    {
                        partitionList = ADForestPartitionInfo.GetForestPartitionInfo(rootDSE).PartitionList;
                    }
                    else
                    {
                        partitionList = rootDSE.NamingContexts;
                    }
                    objArray1[num] = ADForestPartitionInfo.ConcatList(partitionList, " , ");
                    throw new ArgumentException(string.Format(currentCulture, invalidDNMustBelongToValidPartitionSet, objArray));
                }
            }
            return(str);
        }
        private static ADForestPartitionInfo GetForestPartitionInfo(ADSessionInfo sessionInfo)
        {
            ADForestPartitionInfo forestPartitionInfo;

            using (ADObjectSearcher aDObjectSearcher = new ADObjectSearcher(sessionInfo))
            {
                forestPartitionInfo = ADForestPartitionInfo.GetForestPartitionInfo(aDObjectSearcher.GetRootDSE());
            }
            return(forestPartitionInfo);
        }
 private static IEnumerable <string> GetValidPartitionList(ADRootDSE rootDSE, bool refreshForestPartitionList)
 {
     if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC)
     {
         return(rootDSE.NamingContexts);
     }
     else
     {
         if (refreshForestPartitionList)
         {
             ADForestPartitionInfo.GetForestPartitionInfo(rootDSE).Refresh(rootDSE);
         }
         return(ADForestPartitionInfo.GetForestPartitionInfo(rootDSE).PartitionList);
     }
 }