使用 Node.js 应用程序在 Active Directory 中执行搜索查询

Performing search queries in Active Directory with Node.js Application

我正在开发的 Web 应用程序涉及访问此包的 Active Directory in order to perform the necessary authorization and authentication operations. The backend of my application involves nodeJS and it should be using Active Directory NPM package in order to access the Active Directory of my organization. I happen to be totally new to Active Directory and I'm a bit confused with the usage of Active Directory NPM package. I read the usage section,它表明它(配置对象变量)需要用户输入四个参数,如下所示:url、baseDN、用户名和密码。下面是使用部分的代码:

var ActiveDirectory = require('activedirectory');
var config = { url: 'ldap://dc.domain.com',
               baseDN: 'dc=domain,dc=com',
               username: 'username@domain.com',
               password: 'password' }
var ad = new ActiveDirectory(config);

在配置对象中的这 4 个参数中,我无法理解 baseDN 参数的作用以及在 Active Directory 中执行搜索查询时我们必须如何使用它。 (我已经在上图中突出显示了这个参数。)

如果有人能解释这个特定参数的用法以及我们在 Active Directory 中执行搜索查询时如何使用它,那就太好了。

此外,我想知道是否有人可以向我推荐源或教程,这些资源或教程提供了关于使用 Nodejs 应用程序在 Active Directory 中执行搜索查询的清晰解释。任何帮助将不胜感激。谢谢!

基本 DN 的概念并不特定于 Node.js。对于所有 LDAP 查询都是一样的,无论您从哪里进行查询。

DN代表Distinguished Name,是目录中每个对象的标识符。基本 DN(或有时称为 "search root")定义了您的搜索范围。在大多数情况下,baseDN 将是您域的根,例如 DC=example,DC=com(如果您的域名是 example.com)。但是,如果您只想要来自该 OU 的结果,则可以将其设置为特定 OU:OU=Users,DC=example,DC=com.

简而言之:搜索只会 return 结果,其中 DN 以您指定的 baseDN 结尾。

有关如何在 Node.js 中的 AD 中执行查询的文档,您必须参考为此目的创建的包,例如您找到的 activedirectory 包。但是,该软件包不再维护(4 年内未被触及)。 activedirectory2 是从中派生出来的,并得到积极维护。你最好还是用那个。