Пример #1
0
        private bool ExpandForeignGroupSearcher()
        {
            GroupPrincipal item = this.foreignGroups[0];

            this.foreignGroups.RemoveAt(0);
            this.storeCtx = (ADStoreCtx)item.Context.QueryCtx;
            DirectorySearcher directorySearcher = SDSUtils.ConstructSearcher((DirectoryEntry)item.UnderlyingObject);

            directorySearcher.Filter              = "(objectClass=*)";
            directorySearcher.SearchScope         = SearchScope.Base;
            directorySearcher.AttributeScopeQuery = "member";
            directorySearcher.CacheResults        = false;
            this.memberSearchersQueue.Enqueue(directorySearcher);
            string value = (string)((DirectoryEntry)item.UnderlyingObject).Properties["distinguishedName"].Value;

            this.groupsVisited.Add(value);
            return(true);
        }
Пример #2
0
        private bool MoveNextMemberSearcher()
        {
            bool nextSearchResult;
            bool flag = false;

            do
            {
                nextSearchResult = this.GetNextSearchResult();
                flag             = false;
                if (!nextSearchResult)
                {
                    if (!this.recursive || this.groupsToVisit.Count <= 0)
                    {
                        continue;
                    }
                    string item = this.groupsToVisit[0];
                    this.groupsToVisit.RemoveAt(0);
                    this.groupsVisited.Add(item);
                    DirectoryEntry directoryEntry = SDSUtils.BuildDirectoryEntry(this.BuildPathFromDN(item), this.storeCtx.Credentials, this.storeCtx.AuthTypes);
                    this.storeCtx.InitializeNewDirectoryOptions(directoryEntry);
                    DirectorySearcher directorySearcher = SDSUtils.ConstructSearcher(directoryEntry);
                    directorySearcher.Filter              = "(objectClass=*)";
                    directorySearcher.SearchScope         = SearchScope.Base;
                    directorySearcher.AttributeScopeQuery = "member";
                    directorySearcher.CacheResults        = false;
                    this.memberSearchersQueue.Enqueue(directorySearcher);
                    flag = true;
                }
                else
                {
                    SearchResult current = (SearchResult)this.memberSearchResultsEnumerator.Current;
                    string       str     = (string)current.Properties["distinguishedName"][0];
                    if (ADUtils.IsOfObjectClass(current, "group") || ADUtils.IsOfObjectClass(current, "user") || ADUtils.IsOfObjectClass(current, "foreignSecurityPrincipal"))
                    {
                        if (!this.recursive || !ADUtils.IsOfObjectClass(current, "group"))
                        {
                            if (!this.recursive || !ADUtils.IsOfObjectClass(current, "foreignSecurityPrincipal"))
                            {
                                if (this.usersVisited.ContainsKey(current.Properties["distinguishedName"][0].ToString()))
                                {
                                    flag = true;
                                }
                                else
                                {
                                    this.current                 = current;
                                    this.currentForeignDE        = null;
                                    this.currentForeignPrincipal = null;
                                    this.usersVisited.Add(current.Properties["distinguishedName"][0].ToString(), true);
                                }
                            }
                            else
                            {
                                if (!this.usersVisited.ContainsKey(current.Properties["distinguishedName"][0].ToString()))
                                {
                                    this.foreignMembersCurrentGroup.Add(current.GetDirectoryEntry());
                                    this.usersVisited.Add(current.Properties["distinguishedName"][0].ToString(), true);
                                }
                                flag = true;
                            }
                        }
                        else
                        {
                            if (!this.groupsVisited.Contains(str) && !this.groupsToVisit.Contains(str))
                            {
                                this.groupsToVisit.Add(str);
                            }
                            flag = true;
                        }
                    }
                    else
                    {
                        flag = true;
                    }
                }
            }while (flag);
            return(nextSearchResult);
        }