首页 > Windows开发 > 详细

c#取出LDAP SearchResult所有属性

时间:2016-04-28 23:57:02      阅读:450      评论: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

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!