Microsoft Exchange:如何解析可分辨名称

Microsoft Exchange: How To Resolve A Distinguished Name(Microsoft Exchange:如何解析可分辨名称)
本文介绍了Microsoft Exchange:如何解析可分辨名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我该如何解决:

/O=CHEESE/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=LHALA1

发送到电子邮件地址?我必须使用 Exchange 网络服务吗?

to an email address? Do i have to use Exchange Web Services?

推荐答案

我假设这是 legacyExchangeDN 属性.

I'm assuming this is the legacyExchangeDN Attribute.

试试这样的:

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();
    }
}

这篇关于Microsoft Exchange:如何解析可分辨名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

What#39;s the difference between retrieving WindowsPrincipal from WindowsIdentity and Thread.CurrentPrincipal?(从 WindowsIdentity 和 Thread.CurrentPrincipal 检索 WindowsPrincipal 之间有什么区别?)
How do I find a user#39;s Active Directory display name in a C# web application?(如何在 C# Web 应用程序中查找用户的 Active Directory 显示名称?)
How can I authenticate against Active Directory in Nancy?(如何在 Nancy 中对 Active Directory 进行身份验证?)
How to get a username in Active Directory from a display name in C#?(如何从 C# 中的显示名称获取 Active Directory 中的用户名?)
Working with DirectoryServices in ASP.NET Core(在 ASP.NET Core 中使用 DirectoryServices)
Create Active Directory user in .NET (C#)(在 .NET (C#) 中创建 Active Directory 用户)