我从活动目录中获取组名。但我需要这些组的邮件地址,比如gr-all @ blabla ...或者gr-it-software @ blabla ...
这是我获取群组的代码..
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 :(得分:0)
尝试
String Email = result.GetDirectoryEntry.Properties("mail").Value