Question

I have a program that attempts to extract the email address from AD in the following priority: mail, email or userPrincipalName attributes

A client who has Microsoft exchange server is telling me that an incorrect email address is being extracted ie that in in userPrincpalName (shown in windows user properties tab Account, field 'user login name').

In AD explorer I have proved that mail and email attributes are not returned, therefore the software fails-over to userPrincipalName.

The client has shown that the particular AD accessing account has ticked the following permissions:

read account restrictions read exchange information read exchange personal information read general information

However we do not get the email address we see in windows user properties General tab, Email field returned in AD. We do not get mail / email AD attributes in AD Explorer.

I'm not seeing the correct email address anywhere in AD explorer for the user in question.

Can anyone help me understand this better or how we can get the correct attribute back.

Was it helpful?

Solution

The field you are looking for named "proxyAddresses" which is a collection of strings displayed like "SMTP:john.doe@example.com;smtp:j.doe@example.com".

This means that the primary Exchange address is john.doe@example.com and the others (in this example, only j.doe but you can have much more addresses) are the secondary ones.

You can use them like that:

    /// <summary>
    /// Gets the exchange emails.
    /// </summary>
    /// <returns></returns>
    private IEnumerable<string> GetExchangeEmails()
    {
        return (from object property in Entry.Properties["proxyAddresses"] select property.ToString()).ToList();
    }

Hope this answer your question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top