コード例 #1
0
 void Directory_DirGroups(object sender, DirGroupsReplyEventArgs e)
 {
     if (e.MatchedGroups.Count > 0)
     {
         foreach (DirectoryManager.GroupSearchData group in e.MatchedGroups)
         {
             Console.WriteLine("Group {1} ({0}) has {2} members", group.GroupID, group.GroupName, group.Members);
         }
     }
     else
     {
         Console.WriteLine("Didn't find any groups that matched your query :(");
     }
     waitQuery.Set();
 }        
コード例 #2
0
        public void Directory_DirGroupsReply(object sender, DirGroupsReplyEventArgs e)
        {
            Hashtable item = new Hashtable();

            item.Add("MessageType", "DirGroupsReply");
            List <Hashtable> results = new List <Hashtable>();

            foreach (DirectoryManager.GroupSearchData group in e.MatchedGroups)
            {
                Hashtable result = new Hashtable();
                result.Add("GroupID", group.GroupID);
                result.Add("Name", group.GroupName);
                result.Add("MemberCount", group.Members);
                results.Add(result);
            }
            item.Add("Results", results);
            enqueue(item);
        }
コード例 #3
0
        private void Directory_DirGroups(object sender, DirGroupsReplyEventArgs e)
        {
            if (queryID == e.QueryID)
            {
                queryID = UUID.Zero;
                if (e.MatchedGroups.Count < 1)
                {
                    WriteLine("ERROR: Got an empty reply");
                }
                else
                {
                    if (e.MatchedGroups.Count > 0)
                    {
                        /* A.Biondi
                         * The Group search doesn't work as someone could expect...
                         * It'll give back to you a long list of groups even if the
                         * searchText (groupName) matches esactly one of the groups
                         * names present on the server, so we need to check each result.
                         * UUIDs of the matching groups are written on the console.
                         */
                        WriteLine("Matching groups are:\n");
                        foreach (DirectoryManager.GroupSearchData groupRetrieved in e.MatchedGroups)
                        {
                            WriteLine(groupRetrieved.GroupName + "\t\t\t(" +
                                      Name + " UUID " + groupRetrieved.GroupID.ToString() + ")");

                            if (groupRetrieved.GroupName.ToLower() == groupName.ToLower())
                            {
                                resolvedGroupID   = groupRetrieved.GroupID;
                                resolvedGroupName = groupRetrieved.GroupName;
                                break;
                            }
                        }
                        if (string.IsNullOrEmpty(resolvedGroupName))
                        {
                            resolvedGroupName = "Ambiguous name. Found " + e.MatchedGroups.Count.ToString() +
                                                " groups (UUIDs on console)";
                        }
                    }
                }
                GetGroupsSearchEvent.Set();
            }
        }