Ldapsearch to ldapjs conversion(ldapsearch 到 ldapjs 的转换)
问题描述
我一直在尝试转换以下 ldapsearch 查询
I've been trying to convert the following ldapsearch query
ldapsearch -H ldap://ldap.berkeley.edu -x -b 'ou=people,dc=berkeley,dc=edu' objectclass=*
到 ldapjs 脚本:
var ldap = require('ldapjs');
var server = 'ldap://ldap.berkeley.edu';
var searchBase = 'ou=people,dc=berkeley,dc=edu';
var client = ldap.createClient({
url: server
});
var opts = {
filter: '(objectclass=*)'
};
client.search(searchBase, opts, function(err, res) {
res.on('searchEntry', function (entry) {
console.log(entry.toString());
});
});
ldapsearch 给了我很多结果,但 ldapjs 没有返回任何用户.
您可以在 GitHub 上找到解决此问题的一些尝试.
The ldapsearch gives me plenty of results but ldapjs doesn't return any users.
You can find some attempts of solving this on GitHub.
推荐答案
ldapjs 搜索范围是从 UMich 代码派生的 OpenLDAP 和 (AFAIK) 最相似的 C 库的倒退".ldapjs 中的默认范围是base",而不是sub".在没有看到任何数据的情况下,您可能需要使该代码看起来像:
ldapjs search scopes are "backwards" of OpenLDAP and (AFAIK) most similar C libraries that are derived from the UMich code. The default scope in ldapjs is "base", as opposed to "sub". Without seeing any of your data, you probably need to make that code look like:
var opts = {
filter: '(objectclass=*)',
scope: 'sub'
};
client.search(searchBase, opts, function(err, res) {
res.on('searchEntry', function (entry) {
console.log(entry.toString());
});
});
这篇关于ldapsearch 到 ldapjs 的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:ldapsearch 到 ldapjs 的转换
基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
