从单向信任访问用户信息

本文关键字:用户 信息 访问 信任 | 更新日期: 2023-09-27 18:37:08

我有两个域,我的和他们的。MINE 是我的本地域,并且与他们有单向信任(使用 LDAPS 端口 636),因此 MINE 信任他们的,但他们不信任我的。我可以将他们的用户添加到 MINE 中的组,并让来自他们的用户登录到 MINE 网络上的机器和应用程序。信任似乎工作正常。

我正在编写一个小的.Net应用程序(不是 ASP.Net)来测试WAN上的连接。我们有一个应用程序在 MINE 的组中看不到来自 THES 的用户。其他应用程序(如 SharePoint)工作正常。

我尝试将 ASP.Net 4 选项与 System.DirectoryServices.AccountManagement 对象一起使用,如 PrincipalContext、UserPrincipal、GroupPrincipal 等。 快速代码片段

    PrincipalContext domainContext = GetDomainContext(DomainName, ConnectionPort,
        UseSpecifiedCredentials, Credentials);
    GroupPrincipal theGroup = GroupPrincipal.FindByIdentity(domainContext,
        IdentityType.SamAccountName, GroupName);
    PrincipalCollection theUsers = theGroup.Members;
    var users = from u in theUsers
                select u.Name;
    return users.ToArray();

当我直接连接到我的时,一切都很好用。问题在于连接到他们的。LDAPS 流量的 1 向信任返回错误:

System.DirectoryServices.Protocols.LdapException: The LDAP server is unavailable.

所以我使用 DirectoryEntry、DirectorySearcher 等切换到 .Net 2 变体。这实际上适用于他们的域。

    List<string> userNames = new List<string>();
    string searchString = string.Format("(sAMAccountName={0})", GroupName);
    SearchResult result = SearchAD(DomainName, ConnectionPort, searchString);

我可以直接连接到 THEIRS 域,在代码中使用一些模拟。

当我查询 MINE 中的组时,我从他们的那里获取用户的 SID,而不是用户帐户。

The following users are a member of testGroup:
CN=S-1-5-21-....,CN=ForeignSecurityPrincipals,DC=MINE,DC=local
CN=S-1-5-21-....,CN=ForeignSecurityPrincipals,DC=MINE,DC=local

我也尝试了模拟,以他们的用户身份运行它,但没有运气。

当用户在MINE中时,我如何从他们的用户信息中获取用户信息?我必须使用上述CN/SID并查询他们的域吗?我在 .Net 4 中缺少什么?

从单向信任访问用户信息

我假设你的 ASP.NET 机器在我的运行中。

如果您的确保使用其域中的域用户帐户来运行应用程序,则您的 System.DirectoryServices.AccountManagement 方法应该有效。 在正常的单向信任配置中(除非您正在执行选择性身份验证信任),来自 HIS 的域用户帐户应具有从 MINE 和 HIS 读取的权限。

要确保您使用来自其域的域用户,您只需设置 AppPool 身份即可。 当然,您也可以使用模拟来执行此操作。