This code snippet allows you to search Active Directory for a given email address and
returns you the coresponding user object.
String email = testUser@dev.lan;
DirectoryEntry LdapConnection = new DirectoryEntry();
DirectorySearcher search = new DirectorySearcher(LdapConnection);
search.SearchScope = SearchScope.Subtree; search.Filter = "(proxyaddresses=smtp:" + email + ")";
SearchResult result = search.FindOne();
if (result != null) {
DirectoryEntry deDirEnt = result.GetDirectoryEntry();
Console.WriteLine("Address Found");
DirectoryEntry d = deDirEnt.SchemaEntry;
} else {
Console.WriteLine("Address not found!");
}