在windows系统上可以使用下列方法来查找所有的员工邮箱和员工组:

 1 StringDictionary ReturnArray = new StringDictionary();
 2                 Dictionary<string, string> resultDict = new Dictionary<string, string>();
 3                 DirectoryEntry deDirEntry = new DirectoryEntry("LDAP://mail.test.com",
 4                                                                    UserName,
 5                                                                    Password,
 6                                                                    AuthenticationTypes.Secure);
 7 
 8                 
 9 
10                 DirectorySearcher mySearcher = new DirectorySearcher(deDirEntry);
11                 
12                 string sFilter = String.Format("(&(mailnickname=*)(|(objectcategory=user)(objectcategory=group)))");//(objectcategory=user)(objectcategory=group)
13 
14                 mySearcher.Filter = sFilter;
15                 mySearcher.Sort.Direction = System.DirectoryServices.SortDirection.Ascending;
16                 mySearcher.Sort.PropertyName = "cn";
17                 mySearcher.PageSize = 1000;
18 
19                 SearchResultCollection results;
20                 results = mySearcher.FindAll();
View Code

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2021-09-09
  • 2021-04-30
  • 2021-06-29
  • 2022-01-05
  • 2022-12-23
  • 2021-10-22
猜你喜欢
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-08-09
相关资源
相似解决方案