在全局目录中验证用户身份

发布于 2024-08-13 17:17:01 字数 705 浏览 5 评论 0原文

我需要在给定用户 ID、域和密码的情况下验证用户的 Windows 凭据。我们的 Active Directory 包含多个域,我们可以使用以下代码列出其中一些域:

var domains = System.DirectoryServices.ActiveDirectory.Forest.GetCurrentForest().Domains;

但是,我们也有属于林外部域的用户。不过,我可以从全局目录 (GC) 访问它们。下面的代码允许我获取用户 ID 的目录条目。

System.DirectoryServices.DirectoryEntry globalCatalogDE = new System.DirectoryServices.DirectoryEntry("GC://DC=nsroot,DC=net");
var ds = new System.DirectoryServices.DirectorySearcher(globalCatalogDE);
ds.Filter = "(&(objectClass=user)(sAMAccountName=" + userId + "))";
System.DirectoryServices.DirectoryEntry userDE = ds.FindAll()[0].GetDirectoryEntry();

如何对属于我无法直接访问但可以在 GC 中使用的域的用户进行身份验证?

I need to authenticate user's Windows credentials, given a userId, domain and password. Our Active Directory contains multiple domains, some which we can list using the following code:

var domains = System.DirectoryServices.ActiveDirectory.Forest.GetCurrentForest().Domains;

However, we also have users that belong to domains outside the forest. They are however accessible to me from the Global Catalog (GC). Below code allows me to get a directory entry for a userid.

System.DirectoryServices.DirectoryEntry globalCatalogDE = new System.DirectoryServices.DirectoryEntry("GC://DC=nsroot,DC=net");
var ds = new System.DirectoryServices.DirectorySearcher(globalCatalogDE);
ds.Filter = "(&(objectClass=user)(sAMAccountName=" + userId + "))";
System.DirectoryServices.DirectoryEntry userDE = ds.FindAll()[0].GetDirectoryEntry();

How do I authenticate a user that belongs to a domain I can not directly access but is available to me in the GC?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟雨扶苏 2024-08-20 17:17:01

您无法通过查看全局目录来验证用户身份,它仅用于搜索(每个域的架构中用 isMemberOfPartialAttributeSet 标记的任何属性都会复制到 GC)。

密码不会复制到其中;否则,您将在每个域控制器上拥有整个 forrest 中所有用户的密码,从安全和复制的角度来看,这将非常糟糕。您需要建立与存储用户凭据的域的连接(即您需要访问 LDAP 端口 389 或 636)。

You can't authenticate a user by looking in the Global Catalog, it's for searching only (any attribute marked with the isMemberOfPartialAttributeSet in the schema for each domain is replicated to the GC).

Passwords are not replicated to it; otherwise you would have the passwords of all users in the entire forrest on each domain controller which would be very bad from a security and replication standpoint. You need to establish a connection to the domain where the user's credentials are stored (ie you need access to LDAP ports 389 or 636).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文