コード例 #1
0
        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));
            }
        }
コード例 #2
0
        internal static IEnumerable <string> ConstructPartitionList(ADRootDSE rootDSE, IEnumerable <string> partitionList, bool refreshForestPartitionList)
        {
            IEnumerable <string> validPartitionList;
            HashSet <string>     strs       = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
            IEnumerator <string> enumerator = partitionList.GetEnumerator();

            using (enumerator)
            {
                while (enumerator.MoveNext())
                {
                    string current = enumerator.Current;
                    string str     = null;
                    try
                    {
                        str = ADForestPartitionInfo.ConvertFriendlyPartition(rootDSE, current);
                    }
                    catch (ADIdentityNotFoundException aDIdentityNotFoundException)
                    {
                        continue;
                    }
                    if (str == null)
                    {
                        if (!string.Equals(current, "*", StringComparison.OrdinalIgnoreCase))
                        {
                            if (string.IsNullOrEmpty(current) || !ADForestPartitionInfo.IsValidPartitionDN(rootDSE, current, refreshForestPartitionList))
                            {
                                continue;
                            }
                            strs.Add(current);
                        }
                        else
                        {
                            validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                            return(validPartitionList);
                        }
                    }
                    else
                    {
                        strs.Add(str);
                    }
                }
                return(strs);
            }
            return(validPartitionList);
        }