コード例 #1
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");
            }
        }
コード例 #2
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");
            }
        }