码迷,mamicode.com
首页 > Windows程序 > 详细

c#取出LDAP SearchResult所有属性

时间:2016-04-28 23:58:39      阅读:1638      评论:0      收藏:0      [点我收藏+]

标签:

 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);
                    }
                }
            }

c#取出LDAP SearchResult所有属性

标签:

原文地址:http://www.cnblogs.com/furenjian/p/5444609.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!