Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using Exchange Server, proxyAddresses is the most reliable means of getting their email address. The primary smtp address is indicated by all caps "SMTP:" and additional email addresses will be prefixed with lowercase "smtp:". The attribute "mail" does not necessarily have to be the primary SMTP address, though usually it is.</p> <p>Here is a variation of some code I used:</p> <pre><code> public static SearchResult FindAccountByEmail(string email) { string filter = string.Format("(proxyaddresses=SMTP:{0})", email); using (DirectoryEntry gc = new DirectoryEntry("GC:")) { foreach (DirectoryEntry z in gc.Children) { using (DirectoryEntry root = z) { using (DirectorySearcher searcher = new DirectorySearcher(root, filter, new string[] { "proxyAddresses", "objectGuid", "displayName", "distinguishedName" })) { searcher.ReferralChasing = ReferralChasingOption.All; SearchResult result = searcher.FindOne(); return result; } } break; } } return null; } static void Main(string[] args) { SearchResult result = FindAccountByEmail("someone@somewhere.com"); string distinguishedName = result.Properties["distinguishedName"][0] as string; string name = result.Properties["displayName"] != null ? result.Properties["displayName"][0] as string : string.Empty; Guid adGuid = new Guid((byte[]) (result.Properties["objectGUID"][0])); string emailAddress; var emailAddresses = (from string z in result.Properties["proxyAddresses"] where z.StartsWith("SMTP") select z); emailAddress = emailAddresses.Count() &gt; 0 ? emailAddresses.First().Remove(0, 5) : string.Empty; Console.WriteLine(string.Format("{1}{0}\t{2}{0}\t{3}{0}\t{4}", Environment.NewLine, name, distinguishedName, adGuid, emailAddress)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload