【问题标题】:Two active directory forests, find corresponding exchange active directory object / mailbox两个活动目录林,找到对应的交换活动目录对象/邮箱
【发布时间】:2011-05-20 14:10:13
【问题描述】:

我工作的公司有 2 个 Active Directory 林。一个森林叫做我们,我早上用我的个人资料 (us\maflorin) 登录,另一个森林叫做 (mail.us),它专门用于 Exchange。

我创建了一个在 SharePoint 上运行并获取 SPContext.Current.Web.CurrentUser.LoginName 的 asp.net 应用程序,它是美国域的登录名。 (例如对我来说,我们\maflorin)。我想从我们的凭据中获取 Exchange 林中的相应对象,以便将更改写入在直线经理批准流程后打开页面的用户的全局地址列表 (GAL)。

我编写了以下工作代码来获取 Exchange 对象,但它使用两个 ldap 查询来查找对象:

private Dictionary<string,AdRecod> FindExchangeAdProperties(string samAccountName,string description)
 {
        Dictionary<string,AdRecod> properties = null;
        if (!string.IsNullOrEmpty(samAccountName))
        {
            properties = GetUserProperties(@"(&(objectCategory=person)(mailNickname=" +
                                               samAccountName + "))");
            if (properties != null) return properties;
         }

        if ((description == "") || (description == "0"))
            throw new Exception("No matching Description, couldn't find correct Exchange AD object");

        properties = GetUserProperties(@"(&(objectCategory=person)(description=" +
                                       description + "))");
        return properties;
 }

是否可以通过单个 ldap 查询直接从我们的 samAccountName 获取交换对象?

交换林上的 mailNickname 属性并不总是与美国林上的 sAMAccountName 匹配。如果不匹配,我使用第二个 ldap 查询通过查询描述字段来查看是否返回记录。两个林的描述字段多次相同,但有时管理员会更改它。

是否可以更轻松地为 us 域凭据找到相应的 Exchange Active Directory 对象? Outlook 如何从美国凭据中找到相应的邮箱/广告对象?我正在使用 adsiedit 查看 AD 架构,但找不到用于将两个林对象链接在一起的明确字段。

此外,我正在研究交换 Web 服务托管 api(邮箱 dn 属性)的自动发现服务,但您需要将 SMTP 地址传递给 GetUserSettings 方法,并且此字段未填充到美国域。

非常感谢,

马蒂亚斯

【问题讨论】:

  • 你用的是什么版本的交易所?
  • Exchange 2007,感谢您调查此问题

标签: active-directory exchange-server exchangewebservices


【解决方案1】:

我能够通过比上述方法更好的方法找到这个问题的答案,这取决于公司的命名约定。

在交换林中,我使用 DirectorySearcher 类运行 LDAP 查询以获取属性 msExchMasterAccountSid。

然后,以下代码会在我们用于登录的林中提供正确的 sam:

var sid = directoryEntry.Properties["msExchMasterAccountSid"].Value as byte[];
// no mailbox
if (sid == null) continue;

var sidString = new SecurityIdentifier(sid, 0).ToString();
var samAccountName = "";
using (var context = new PrincipalContext(ContextType.Domain, "US"))
{
       var principal = UserPrincipal.FindByIdentity(context, IdentityType.Sid, sidString);
       if (principal == null) continue;
       samAccountName = principal.SamAccountName;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-14
    • 1970-01-01
    相关资源
    最近更新 更多