问题
How can i resolve this:
/O=CHEESE/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=LHALA1
to an email address? Do i have to use Exchange Web Services?
回答1:
I'm assuming this is the legacyExchangeDN Attribute.
Try something like this:
string dn = "/O=CHEESE/OU=FIRST ADMINISTRATIVE GROUP/" +
"CN=RECIPIENTS/CN=LHALA1";
string MailAddress=string.Empty;
string user = string.Empty;
using (DirectorySearcher ds = new DirectorySearcher())
{
ds.Filter = string.Format("(&(ObjectClass=User)(legacyExchangeDN={0}))",
dn);
SearchResultCollection src = ds.FindAll();
if (src.Count > 1)
{
//Oops too many!
}
else
{
user = src[0].Properties["samAccountName"][0].ToString();
MailAddress = src[0].Properties["Mail"][0].ToString();
}
}
回答2:
If you can do an LDAP search of the directory you can retrieve the entry for that user and then the default email address will be in the mail: attribute
If it is a mailbox-enabled Exchange user there will also be addresses in the proxyAddresses: attribute, of a contact or a non-mailbox mail-enabled user there will be remote addresses in the targetAddress: attribute
来源:https://stackoverflow.com/questions/17168066/microsoft-exchange-how-to-resolve-a-distinguished-name