首页 > 其他 > 详细

csharp - retrieve LDAP

时间:2018-02-09 19:09:06      阅读:176      评论:0      收藏:0      [点我收藏+]
 1 DirectoryEntry de = new DirectoryEntry("LDAP://10.10.10.10:389");
 2             DirectorySearcher searcher = new DirectorySearcher(de, string.Format("(&(objectClass=user)(samAccountName={0}))", "A00106"));
 3             SearchResultCollection src = searcher.FindAll();
 4             foreach (SearchResult rs in src)
 5             {
 6                 if (rs != null)
 7                 {
 8                     string n = (rs.GetDirectoryEntry().Properties["distinguishedName"].Value == null) ? string.Empty : rs.GetDirectoryEntry().Properties["distinguishedName"].Value.ToString();
 9                     if (n.IndexOf("OU") != -1)
10                     {
11                         //displayName,sAMAccountName,name,mail
12                         string email = (rs.GetDirectoryEntry().Properties["mail"].Value == null) ? string.Empty : rs.GetDirectoryEntry().Properties["mail"].Value.ToString();
13                     }
14                 }
15             }

 

csharp - retrieve LDAP

原文:https://www.cnblogs.com/dufu/p/8436223.html

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