我该如何解决:
/O=CHEESE/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=LHALA1
电子邮件地址?我必须使用 Exchange Web 服务吗?
我假设这是 legacyExchangeDN 属性。
尝试这样的事情:
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();
}
}
我是一名优秀的程序员,十分优秀!