c#SearchResultCollection的所有属性

 string aaa = System.Threading.Thread.CurrentPrincipal.Identity.Name;

            DirectorySearcher ds = new DirectorySearcher();
            ds.SearchRoot = new DirectoryEntry("LDAP://888.888.0.11/CN=Users,DC=***,DC=com", "***", "***");
            ds.Filter = "(objectClass=user)";
            ds.SearchScope = SearchScope.Subtree;
            ds.Sort = new SortOption("Name", System.DirectoryServices.SortDirection.Ascending);
            ds.PageSize = 1024;
            SearchResultCollection rs = ds.FindAll();

            foreach (SearchResult r in rs)
            {
                ResultPropertyCollection rprops = r.Properties;
                string prop = null;
                foreach (string name in rprops.PropertyNames)
                {
                    foreach (object vl in rprops[name])
                    {
                        prop = name + ":" + vl.ToString();
                        ls.Add(prop);
                    }
                }
            }

posted @ 2010-01-05 10:08  dodo-yufan  阅读(2000)  评论(0编辑  收藏  举报