コード例 #1
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);
        }
コード例 #2
0
        private static bool IsValidPartitionDN(ADRootDSE rootDSE, string partitionDN, bool refreshForestPartitionList)
        {
            bool flag;

            if (rootDSE != null)
            {
                if (partitionDN != null)
                {
                    if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC || !partitionDN.Equals(string.Empty))
                    {
                        IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                        IEnumerator <string> enumerator         = validPartitionList.GetEnumerator();
                        using (enumerator)
                        {
                            while (enumerator.MoveNext())
                            {
                                string current = enumerator.Current;
                                if (!ADPathModule.ComparePath(partitionDN, current, ADPathFormat.X500))
                                {
                                    continue;
                                }
                                flag = true;
                                return(flag);
                            }
                            return(false);
                        }
                        return(flag);
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    throw new ArgumentNullException("partitionDN");
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }
コード例 #3
0
        internal static string ExtractPartitionInfo(ADRootDSE rootDSE, string objectDN, bool refreshForestPartitionList)
        {
            string str = null;

            if (rootDSE != null)
            {
                if (objectDN != null)
                {
                    if (rootDSE.SessionInfo == null || !rootDSE.SessionInfo.ConnectedToGC || !objectDN.Equals(string.Empty))
                    {
                        IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                        int length = -1;
                        foreach (string str1 in validPartitionList)
                        {
                            if (str1.Length <= length || !ADPathModule.IsChildPath(objectDN, str1, true, ADPathFormat.X500))
                            {
                                continue;
                            }
                            length = str1.Length;
                            str    = str1;
                        }
                        return(str);
                    }
                    else
                    {
                        return(string.Empty);
                    }
                }
                else
                {
                    throw new ArgumentNullException("objectDN");
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }
コード例 #4
0
        internal static bool IsDNUnderPartition(ADRootDSE rootDSE, string objectDN, bool refreshForestPartitionList)
        {
            bool flag;

            if (rootDSE != null)
            {
                if (!string.IsNullOrEmpty(objectDN))
                {
                    IEnumerable <string> validPartitionList = ADForestPartitionInfo.GetValidPartitionList(rootDSE, refreshForestPartitionList);
                    IEnumerator <string> enumerator         = validPartitionList.GetEnumerator();
                    using (enumerator)
                    {
                        while (enumerator.MoveNext())
                        {
                            string current = enumerator.Current;
                            if (!ADPathModule.IsChildPath(objectDN, current, true, ADPathFormat.X500))
                            {
                                continue;
                            }
                            flag = true;
                            return(flag);
                        }
                        return(false);
                    }
                    return(flag);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                throw new ArgumentNullException("rootDSE");
            }
        }