예제 #1
0
        private int fillTreeView(string searchBaseDn, string ldapFilter = null)
        {
            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();

            // 搜尋 Base DN 本身,只驗證存在與否,不做過濾
            Dictionary <string, List <AttributeDataModel> > result = ldapHelper.Search(searchBaseDn, searchScope: SearchScope.Base);

            // 搜尋 Base DN 的所有後代,並做過濾。將所有搜尋結果納入樹狀結構。
            int resultCount = result.Count; // 應只有一筆

            foreach (var item in result)
            {
                TreeNode treeNodeRoot = treeView1.Nodes.Add(item.Key);
                treeNodeRoot.Tag = item.Value; // 用Tag儲存該物件的Attributes.
                resultCount     += searchChildren(treeNodeRoot, ldapFilter);
            }

            treeView1.EndUpdate();
            treeView1.ResumeLayout();

            return(resultCount);
        }