2014-01-22 31 views
0

我从活动目录获取组名称。但我需要邮寄这些团体,如GR-所有@布拉布拉......或GR-IT软件@布拉布拉的地址...如何获得ActiveDirectory组邮件地址

这里是我让组代码..

string groupName = String.Empty; 
      int startIndex = 0; 
      DirectoryEntry de = new DirectoryEntry("LDAP://blabla"); 
      DirectorySearcher searcher = new DirectorySearcher(de); 
      searcher.Filter = "(&(&(objectClass=group)(objectcategory=group))(name=*" + pSearchText + "*))"; //this contain filter for adgroups from textbox 
      searcher.PropertiesToLoad.Add("name"); 
      SearchResultCollection results = searcher.FindAll(); 
      foreach (SearchResult result in results) 
      { 
       de = result.GetDirectoryEntry();//de object has a lot of properties but not include e mail address, or it is include I can't see that. 
       groupName = de.Name; 
       startIndex = groupName.IndexOf('=') + 1; 
       groupName = groupName.Substring(startIndex, groupName.Length - startIndex); 
       groupNames.Add(groupName); 

回答

0

尝试

String Email = result.GetDirectoryEntry.Properties("mail").Value 
相关问题